It's monday and now I can see the answer! :-) The RenderChildren should be aware of RenderMethod. So, for a Form control the RenderChildren should be something like:
output.WriteBeginTag(etc); output.WriteAttrs(etc); invoke delegate; output.WriteEndTag(etc); Pretty simple. hammett MCAD ----- Original Message ----- From: "hammett" <[EMAIL PROTECTED]> To: <[EMAIL PROTECTED]> Sent: Friday, July 04, 2003 6:08 PM Subject: [ADVANCED-DOTNET] Asp.net RenderMethod magic > (I'm posting this question here cause I think it is an advanced issue) > > For whose who don't know, when you add code inside some runat="server" tag, > the control receives a delegate (a RenderMethod delegate to be more > precise). The control should not render in it's normal way as it should > first check if someone provided a RenderMethod delegate before rendering. > > To know how things work I subclassed a HtmlGenericControl and added some > code contents, like this: > > <form id="Form1" method="post" runat="server"> > <www:webcustomcontrol1 runat="server" id="cont"> > <% = "hello" %> > <p> </p> > <INPUT type="button" value="Button"> > </www:webcustomcontrol1> > </form> > > (the control should render itself as a SPAN tag). ASP.Net generated the > usual method for the delegate: > > private void __Rendercont(System.Web.UI.HtmlTextWriter __output, > System.Web.UI.Control parameterContainer) > { > __output.Write("\r\n\t\t\t\t"); > __output.Write("hello"); > __output.Write("\r\n\t\t\t\t<p> </p>\r\n\t\t\t\t<INPUT > type=\"button\" value=\"Button\" />\r\n\t\t\t"); > } > > So far, so good. As the Page's render begins, it calls the public > RenderControl(output) method that should call RenderChildren and recursively > render all controls. > > But, wait! How things should work when they reach my control? > > My-brain output begins: > > The recursive call into RenderControl of my control begins > The control have a render delegate, so invoke it > ASP.Net generated render method is called > Render finished for the control (every child control should be handled in > the render method) > > End of my-brain output > > I'm believer that it is the way rendering works for controls with render > methods hidden by render delegates. But, I notice something strage. Where is > the call to the control render method? In this case it should render a SPAN > tag - and it does! - but where? And if someone provide (override) the render > method and write something like: > > protected override void Render(HtmlTextWriter output) > { > output.WriteBeginTag... etc > output.WriteSomethingElse etc > output.WriteEndTag... > } > > Where's the render method fits? Nowhere, I think. > > > Well, it's friday. Maybe the answer is jumping in front of me right now, but > I can't see it - maybe the answer is the RenderChildren... Any thoughts? > > > Regards, > > hammett > MCAD >