Hi, I have made a little custom control which has collection of inner properties. I've also successfully tested a custom control which accepted "literal content" (innertext) into a default property. I have both models working separately, but I'd like to combine the two into one control. That is, I want to define my control on the page like this:
<mystuff:sitemenu runat="server">
<menuitem name="something" url="something.aspx" />
<menuitem ... />
some literal content here which ends up in a default property string
</mystuff:sitemenu>
My code for the control, which is working with the inner properties (but not the literal content) is as follows:
Namespace mystuff
<ParseChildren(True, "menuitem")> _
<PersistChildren(False)> _
Partial Public Class sitemenu
Inherits System.Web.UI.UserControl
Private _menuitems As New Hashtable
<PersistenceMode(PersistenceMode.InnerProperty)> _
Public Property menuitem() As clsMenuItem
(get and set stuff - adds instances of clsMenuItem to _menuitems hashtable)
End Property
Public Class clsMenuItem
(defines properties which are the attributes for each menuitem)
End Class
End Namespace
The above is working for inner properties of the control. I have added some code to the above (see below), which the *IDE* accepts as allowing the literal content (no wiggly error lines appear yay!) but when I run the page, the HTML parser throws the error "Literal content is not allowed within (my user control)"
This is what I added (as well as changing the default property of the class to "myliteralcontent"):
<PersistenceMode(PersistenceMode.EncodedInnerDefaultProperty)> _
Public Property myliteralcontent() As String
(gets and sets)
End Property
That resulted in the IDE playing nice and recognising the literal content as well as the inner properties! But the runtime parser is the problem. What do I need to add to my code to get the parser to accept the literal content?
Many thanks if anyone can help!