Inject custom web controls into a string

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

H

I'm struggling to think this one through

At run time I want to be able to read a layout HTML file from a database which includes tags for modules, e.g

<HTML><BODY><table><tr><td><ModuleTag>1</ModuleTag></td><td><ModuleTag>2</ModuleTag></td></tr></table></BODY></HTML

I would then like to, at run time, interpret the module tags and replace them with custom web controls (e.g., Announcement, Article). The reason for doing this at run time is that I do not know the structure of the layout (there could be more tags placed in a more complex layout)

I could tackle it as follows
* Have a page (Page.aspx) with a PlaceHolder (phLayout)
* Split the layout html at the module tags to end up with a collection of controls (literals and custom
- Literal1 = "<HTML><BODY><table border=\"0\" cellpadding=\"0\" cellspacing=\"0\"width=\"100%\"><tr><td>
- CustomWebControl1 = Module
- Literal2 = "</td><td>
- CustomWebControl2 = Module
- Literal3 = "</td></tr></table></BODY></HTML>
* Add the controls to the placeholde

Is there a simpler way

Thanks
Steven
 
You have a good idea, using a PlaceHolder control is pretty
straightforward.Take a look at the Community Starter Kit on
http://www.asp.net. It will dynamically load user controls (in ascx
files) into the placeholders using LoadControl. The control to load
depends on various cutomization settings, so this type of architecture
allows for dramatic changes in content layout in a simple manner.
 
Back
Top