Default toolbox tab for custom control?

A

Arthur Dent

Is there any attribute i can add to a custom control class, similar to
<ToolboxData()> which would allow me to set a default tab in the toolbox
whihc a control should be added to? Id like to make my controls so that they
automatically add themselves to a tab for my own controls, named after my
company for example.

Thanks in advance,
- Arthur Dent.
 
A

Alessandro Zifiglio

hi Arthur, you can use the WebControlToolboxItem for this : there is some
sample code in the following reference.
http://msdn2.microsoft.com/en-US/library/system.web.ui.design.controlpersister(VS.80).aspx

Specifically you want to look at the designer class in the sample code and
how they implement the following :

// Create a Web control toolbox item for the type of the control
System.Web.UI.Design.WebControlToolboxItem item =
new
System.Web.UI.Design.WebControlToolboxItem(ctrl.GetType());

// Add the Web control toolbox item to the toolbox
IToolboxService toolService = (IToolboxService)
this.Component.Site.GetService(typeof(IToolboxService));
if (toolService != null)
toolService.AddToolboxItem(item);
else
throw new Exception("IToolboxService was not found.");


Have a good easter,
Alessandro Zifiglio
 

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,774
Messages
2,569,596
Members
45,143
Latest member
SterlingLa
Top