Custom control in toolbox, intellisense?

Below is some custom control code to create a tab strip taken from ASP.NET
2.0 Unleashed by Stephen Walther. It works, but I need to clarify some
things...

1.) Both "ServerTabs" and "ServerTab" appear in the VS toolbox when I add
the control. How can I just get "ServerTabs" appear (i.e. ListItem doesn't
appear with DropDownList but it still appears in Intellisense like below).
The "ServerTab" is dependent on "ServerTabs" so I don't want it to appear on
the toolbox. When I try to hide it using [ToolboxItem(false)], it won't
appear in Intellisense then..how do I get it to work like this

Advertisements

semantics between ServerTabs and DropDownList are bit different. First,
ListItem is not a control where as ServerTab is. DropDownList uses ListItem
objects to render out <OPTION> tags, but ListItems are never part of
DropDownList's Controls collection (they are not child controls of DDL).
ListItems have their own collection, ListItemCollection, which
DropDownList.Items property represents. When ListItems are specified in
declarative syntax, they are added to the Items collection, from where
DropDownList then iterates them at render time.

If you want this type of functionality, you would need to take a bit another
approach and have ServerTab as non-controls and available as complex
property (Tabs) on the ServerTabs control. It would certainly make the
control more complex since you would then need to have ITemplate properties
etc

Advertisements

Thank you! I would really like to learn more about this type of development.
Can you recommend sources on the topics you mentioned specifically using
ITemplate?

As for my specific questions.

1) Can I only show "ServerTabs" and hide "ServerTab" on the toolbox in VS?
In other words, don't show child controls on the toolbar.
2) If I implement the ControlBuilder using "tab" tags as checked in the
GetChildControlType, can I make "tab" tags part of Intellisense?

1. Yes, by taking the change I mentioned and having ServerTab as non-control
(sure ToolBoxItem hides it, but also removes it from Intellisense)

2. Making tab available in Intellisense as I understand you wanting it,
requires you to have the collection property (for ServerTab objects) within
your custom control, in case you want it to work in sync with your question
1. Using ControlBuilder means that you take approach that content between
control's tags is mapped to child controls, while the approach I'm trying to
bring yto ou, is that content between control's tag is mapped to its
properties e.g you don't have control builder.

The best resource about control development is MSPress's book Developing
ASP.NET Server Control and Components. Then there are some good articles:

Share This Page

Welcome to The Coding Forums!

Welcome to the Coding Forums, the place to chat about anything related to programming and coding languages.

Please join our friendly community by clicking the button below - it only takes a few seconds and is totally free. You'll be able to ask questions about coding or chat with the community and help others.
Sign up now!