|
|
|||||||||
|
|||||||||
|
|||||||||
| |
|||
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Display Modes |
|
|
|
SlickEdit: Code in over 40 languages across 7 platforms. SlickEdit’s unmatched power, speed, and flexibility allows even the most accomplished developers to write better code faster. Download a free trial today! |
|
#1
|
|||
|
|||
|
Template system tutorial for ASP.NET ?
I'm in the process of writing a small web app that will allow intranet users to create their own page to display personal info, hobbies, that sort of thing.
While it's easy to create the d/b entries and pull them into a standard page, I was thinking of allowing each user to define their own template page so they can "express their individuality". I had in mind a system where they could use a normal html page designed in frontpage, with a few placeholder tags like [%Name%] which I could parse by reading the template file into the main display aspx page using the fso and using the replace function to insert the dynamic data before writing the new page. The problem with this approach is that you have to manually define the replace function in each page, and recode whenever you want to add a new tag. Is there a way to make tag creation independent of the parse page ? ie A seperate tag definition file that's read by the page that parses the template ? Are there any predefined classes or components that have this functionality ? |
|
#2
|
|||
|
|||
|
Make a server control that uses templates. Make it so taht it takes in a datasource object..
When you do this, you can either assign templates using <itemtemplate> like datalist and repeater in aspxpage or u can just pull an user control as a template in runtime.... since u want to have a separate page as template, 2nd option might do the trick for ya... and the template page would have somethign like <%# ((ObjectNameOfDataSource)Container.DataItem).Prope rtyName%> neway try researching in to the areas of server controls...
__________________
Regards, James Yang .NET Developer / Network Engineer MCSE, MCDBA, MCSA, CCNA http://www.yellowpin.com/ http://www.opentechsupport.com/ |
|
#3
|
|||
|
|||
|
Thanks, James. Makes sense, and I'll definitely investigate the user control option. From what I understand of it, I should be able to just do a replace and substitute the tag for the ascx page in the aspx page, which would in turn parse the html template.
Should be fun to try get this working. ![]() |
|
#4
|
|||
|
|||
|
well just ot make it clearer
you konw how repeater has a <ItemTemplate> tag thingy to assign template to the control??? well other way to assign template to the repeater is like this Repeater1.ItemTemplate = Page.LoadTemplate("usercontrol.ascx") so userControl can be the template and the properties of the object u assign to its DataSource property can be displayed dynamically using <%# Container.DataItem ... %> thingy here is a link to start you off!! http://msdn.microsoft.com/library/d...rvercontrol.asp hope this helps |
![]() |
| Viewing: Dev Articles Community Forums > Programming > ASP Development > Template system tutorial for ASP.NET ? |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|