Is there any way to read some HTML and replace that HTML with a PlaceHolder control dynamically at runtime?
For example, I have some HTML that contains tags such as ##MainContent## or ##SideContent##.
I need to somehow find each tag and dynamically add a asp:PlaceHolder control.
EDIT – The reason for this is to read the HTML in and then dynamically add controls to a section of the page. I’m attempting to create a CMS system, although I’m not sure this is the best approach.
I hope this is a thought exercise. 🙂
Ideally, you should just replace those tags in your markup with an
<asp:PlaceHolder>control. If you cannot do that (for whatever reason), try replacing them with an<asp:Literal>control:That way, they will still render on the page exactly as they do now. Then you should be able to use
litMainContentandlitSideContentin your code-behind:For VB.Net:
For C#.Net