Last post May 09, 2005 09:07 AM by uid639299
May 05, 2005 04:47 PM|uid639299|LINK
If I have a custom control named <cc1:test>Test Content</cc1:test>, is there anyway to pull out the content in the middle of the control? My control code can be found below. Any help would be appreciated.
<Description("Header Class Name")>
<Description("Hyperlink Class Name")>
May 05, 2005 06:47 PM|Caddre|LINK
You need the IPostBackDataHandler Interface to get data back from your control and it has all the events you need. Try the link below. Hope this helps.
May 06, 2005 10:45 PM|imagemaker|LINK
I'm not sure, but what I think you're asking is how to access the inner content that appears between the beginning and closing tags of your custom control - that is, the text "Test Content" in your example.
How you do this depends on what the inner content consists of - is it a simple string (which will be parsed as a literal control) or is it one or more child controls.
If it is always a simple string and supposing it corresponds to your "pageName" property the following would work:
1. Add the following attributes to your class definition:
ParseChildren(False, "pageName"), PersistChildren(True)> _Public Class Test Inherits Control
2. Modify the pageName property as follows:
<Description("Page Name"), DesignerSerializationVisibility(DesignerSerializationVisibility.Visible), _ PersistenceMode(PersistenceMode.EncodedDefaultInnerProperty)> _Public Property pageName() As String Get EnsureChildControls() Return Me.lblHeader.Text End Get Set(ByVal Value As String) EnsureChildControls() Me.lblHeader.Text = Value End SetEnd Property
2. Add an override of the AddParsedSubObject method as follows:
Protected Overrides Sub AddParsedSubObject(ByVal obj As Object) If TypeOf obj Is LiteralControl Then Me.Text = CType(obj, LiteralControl).Text End IfEnd Sub
If the inner content is NOT a simple string, then the AddParsedSubObject gets more complicated.
If I've totally misunderstood your question, please try to explain in more detail what you mean by
"is there anyway to pull out the content in the middle of the control."
May 09, 2005 09:07 AM|uid639299|LINK
Im looking to pull out HTML and other controls. If this is to complex, thats fine. I was just trying to merge 3 user controls I have together and use the inner content as the content in between my controls.