I am sure this question has been asked and answered; but I haven't managed to find it...
I am creating a very simple custom System.Web.UI.Control that has a few properties. I can define in my ASPX page the following tag and everything is happy:
<ns:MyControl runat="server" MyProperty="Value" />
However, if I want to have one or more "child" properties, like so:
<ns:MyControl runat="server" MyProperty="Value">
<Element AnotherProperty="AnotherValue1" />
<Element AnotherProperty="AnotherValue2" />
</ns:MyControl>
I cannot figure out what I need to do to make the XHTML validate. I always have
- Content is not allowed between the opening and closing tag of element 'XXX'
- Element 'XXX' is not supported
- The name contains uppercase characters, which is not allowed
The code actually runs as expected, but I haven't manged to find a good example on how to do this correctly so that everything validates. In terms of implementation of the Custom Control, I just have all properties stubbed out at the moment, and looks something like:
[ParseChildren(true)]
[PersistChildren(false)]
public class MyControl : Control
{
public String MyProperty { get; set; }
public String Element { get; set; }
}
Ultimately, Element is intended to build up a collection of Elements. Any insight on how to do this properly and have the XHTML validate would be greatly appreciated.
Thanks in advance.