By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,853 Members | 1,563 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,853 IT Pros & Developers. It's quick & easy.

ASP.NET Templated User Controls - Limit child controls allowable within a templated control

P: n/a
I have a templated user control which looks like this:

<uc:MyUserControl runat=server>


Currently i can drop any html/web controls/user controls into
TemplateProperty. I then handle these inside of my user control, in
the PreRender, I do run:
_templateProperty.InstantiateIn(aPlaceHolderInside UserControl);

This all works. Very nice, allows for great content encapsulation.

Now, what I would like to do next is limit what controls are allowable
INSIDE of the TemplateProperty. An example would be only allowing
'asp:Label' to be used, or as in my case, another usercontrol which
I've created.

So idealy, once one types:
<Template Property>

intelisense only allows you to populate the Template Property with
controls that are allowable, i.e. asp:Label, or a another specified
user control, or something of that nature.

ASP.NET actually already does this with some webcontrols. for an
example, look at:
<asp:DataGrid runat=server>

inside of the Templated Property, Columns, one can only choose from:
<asp:BoundColumn />
<asp:ButtonColumn />
<asp:EditCommandColumn />
<asp:HyperLinkColumn />
<asp:TemplateColumn />

Any other control inserted in <Columns> will cause compile errors:
Error 4 Validation (ASP.Net): Text is not allowed between the opening
and closing tags for element Columns'.

I'd like to have this same functionality with my controls. Any help
would be greatly appreciated!

Thanx Much,
John Pequeno
.... just another Computer Engineer

May 29 '06 #1
Share this question for a faster answer!
Share on Google+

This discussion thread is closed

Replies have been disabled for this discussion.