Hi,
I'm trying to limit the possible types of controls that can be put in to the templated area of a templated control in ASP.NET. Does anyone know how to do that?
/Asger
Hi,
I'm trying to limit the possible types of controls that can be put in to the templated area of a templated control in ASP.NET. Does anyone know how to do that?
/Asger
I'm not sure it makes sense to do this with a template, per se. A template is a property of type ITemplate. I suppose your designer code could attempt to limit what goes into the template, but that's really against the paradigm.
Perhaps what you want is to override the Control.AddParsedSubObject method, or else implement a ControlBuilder to get serious about it.
John, Thank you very much for those pointers! That'll get me further. I'm not quite sure, why it doesn't make sense though... for example inside a DataGrids column property only certain child-controls are allowed:
BoundColumn ButtonColumn EditCommandColumn HyperLinkColumn
Any other control inserted in will cause compile errors: Error 4 Validation (ASP.Net): Text is not allowed between the opening and closing tags for element Columns'.
/Asger