When building a custom control, how would you access the content between the opening and closing control tags?
<my:tag runat="server">
<p>...markup</p>...
</my:tag>
I am currently successfully using the Render method to output arbitrary markeup, but cannot seem to find out how to access the contained markup.
Take a look at
this.Controls. This article :http://msdn.microsoft.com/en-us/library/system.web.ui.control.controls(VS.71).aspx states “On an ASP.NET page, when controls are added declaratively between the opening and closing tags of a server control, ASP.NET automatically adds the controls to the containing server control’s ControlCollection. ”
As far as I understand, if you have
Then it would be possible to call
this.FindControl("innerP").text="Other text here, since the P tag is generated on the server side.However, if you do not have the
runat="server"set on the P element:then you only can only find it through
this.controls[0]since all the content will be rendered into a singleLiteralcontrol.