Content is not allowed between the opening and closing tags for user control
.net, asp.net, c#, user-controls
Solution
I believe you just need to apply a couple of attributes to the control:
[ParseChildren(false)]
[PersistChildren(true)]
public class MyDiv : UserControl
{
...
You may then need to override `AddedControl` - I'm not sure.
Put it this way - that's what works for the one and only user control I've ever written :)
Problem
I want to build a user control suppose MyDiv.ascx. This control renders the div tag and do few more code behind stuff like adding few attributes etc which is not a matter of concern here. The problem is I want text between the opening and closing tags of the user control. Eg: The text goes here with some other HTML tags. So when do something like this I get a parsing error while running the website. Also VS2008 warns me by saying "Content is not allowed between the opening and closing tags for element MyDiv". Question 1: Can I do something like this i.e. text/markup between opening and closing tags of a user control? Question 2: If yes, how