Limit what controls are allowed within another control?

D

Dave

In buidling custom web controls, what do you have to do to restrict what
controls are allowed inside the parent control and so only the allowable
nested ones appear in intellisense (i.e ListBox is the only thing displayed
in a DropDownList control). Anything to illustrate in the right direction to
build controls this way would be helpful. Thanks.
 
B

Brennan Stehling

By default a new custom control will use the span tag. But you can
change that by overriding the TagKey property. It returns a
HtmlTextWriterTag. In the case of a list control, it returns
HtmlTextWriterTag.Select. Below is the C# code to do that.

protected override HtmlTextWriterTag TagKey
{
get
{
return HtmlTextWriterTag.Select;
}
}

You can find more here...

http://msdn2.microsoft.com/en-us/library/f820d25y.aspx

Brennan Stehling
http://brennan.offwhite.net/blog/
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,764
Messages
2,569,566
Members
45,041
Latest member
RomeoFarnh

Latest Threads

Top