views:

69

answers:

0

I am building an ASP.NET server control which extends CompositeControl.

I need fine grained control over the rendering, so I override Render() and output the child controls myself, interspersed with HTML generation code:

writer.AddStyleAttribute("float", "left");
writer.RenderBeginTag(System.Web.UI.HtmlTextWriterTag.Div);
writer.RenderBeginTag(System.Web.UI.HtmlTextWriterTag.Strong);
writer.Write("Table");
writer.RenderEndTag(); // strong
writer.WriteBreak();
tableList.RenderControl(writer);
writer.RenderEndTag(); // div

This works really well for user controls that just contain simple controls without children of their own.

However, if I want to use something like a MultiView or an UpdatePanel I run into problems, since I can't override Render() on View or UpdatePanel without extending them, and if I do extend them the implementation would presumably have to depend on FindControl() voodoo to get references to the right controls during render.

That doesn't sound like the right way to do this - is there a better way?

Edit: I have just built an implementation of View that works using FindControl() and it actually works rather well. Still interested to see other methods though.