Last post Sep 26, 2009 01:02 AM by sandwedgie
Sep 17, 2009 09:43 AM|sandwedgie|LINK
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. That is, I want to define my control on the page like this:
<menuitem name="something" url="something.aspx" />
some literal content here which ends up in a default property string
My code for the control, which is working with the inner properties (but not the literal content) is as follows:
<ParseChildren(True, "menuitem")> _
Partial Public Class sitemenu
Private _menuitems As New Hashtable
Public Property menuitem() As clsMenuItem
(get and set stuff - adds instances of clsMenuItem to _menuitems hashtable)
Public Class clsMenuItem
(defines properties which are the attributes for each menuitem)
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"):
Public Property myliteralcontent() As String
(gets and sets)
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!
Sep 20, 2009 10:58 PM|Allen Chen – MSFT|LINK
This can be done by using custom ControlBuilder:
Public Class MyControlBuilder
Public Class MySubControl
Public Class MyControl
Private Property SubControl() As MySubControl
Set(ByVal value As MySubControl)
protected override void AddParsedSubObject(Object obj)
Sep 26, 2009 01:02 AM|sandwedgie|LINK
Thanks Allen, I'll give that a try!