Last post Mar 26, 2008 11:07 PM by Nai-Dong Jin - MSFT
Mar 24, 2008 01:20 PM|antallison|LINK
My basic question is, what are the pros/cons to these 2 approaches for creating a custom web server control that will contain wide-open markup in one of its properties:
- Use templates for the property that will handle all of this content
- Use ParseChildren(false) and just allow child controls to render themselves
I was thinking that templates are more for expose extensibility for a certain portion of a control (like column header templates, etc), but it this case, where I'm creating a custom container sort of like Panel, etc, it doesn't seem to fit as well as the
I took a look at the System.Web.UI.Panel class, and it looks like it takes the ParseChildren(false) approach, but perhaps templates offer some additional features that would make them work here as well.
Any feedback would be appreciated.
Mar 26, 2008 11:07 PM|Nai-Dong Jin - MSFT|LINK
From your description, it seems that you want to create a custom container sort of like Panel, right?
If so,why don’t you use PersistChildren(true) attribute for your custom server control?
Since for panel controls or other container controls, they are used to persisting children controls. So you should parse the content as Child controls instead of
attributes. And ‘PersistChildren(true)’ indicates that the contents in children control are persisted as server controls.