3

i have an ASP.net UserControl that i want to use:

enter image description here

Following the instructions in Visual Studio:

There are no usable controls in this group.
Drag an item onto this text to add it to the toolbox.

i try dragging the item onto that text to add it to the toolbox:

enter image description here

Unfortunately, dragging an item onto that text does not add it to the toolbox:

enter image description here

So that raises the question:

How do i drag a UserControl into the Toolbox?

Note

  • building, or rebuilding, does not automatically add the control to the toolbox
  • the Choose Items dialog does not include user controls
Ian Boyd
  • 246,734
  • 253
  • 869
  • 1,219

3 Answers3

5

You don't. Just drag the UserControl from the solution explorer onto the design surface. No need to add it into the toolbox first.

Here is a relevant article in the asp.net forum.

Marcel
  • 15,039
  • 20
  • 92
  • 150
2

Is the following link of any help

http://dhavalupadhyaya.wordpress.com/2008/07/20/how-to-add-custom-control-in-visual-studio-toolbox/

Gagan
  • 5,416
  • 13
  • 58
  • 86
  • 1
    Unfortunately not. That's for a control that resides in a separately compiled assembly (*.dll) – Ian Boyd Jul 26 '12 at 01:40
  • In that case, i dont think you will be able to drop and ascx file from the solution explorer to the toolbox. I think VS expects an assembly as a drop element and not an object of type 'ascx" as the drop element. If you dont mind, can i put forth a suggestion , please which i am sure you would know.. having the controls in a separate assembly is always a good idea.. :) – Gagan Jul 26 '12 at 05:01
  • i've actually been doing a lot of work [to get rid of separate assemblies](http://stackoverflow.com/questions/262251/visual-studiosource-control-how-to-have-shared-code); [copying code out of separate assemblies into the native solution](http://stackoverflow.com/questions/1116465/how-do-you-share-code-between-projects-solutions-in-visual-studio). Makes things so much better. – Ian Boyd Jul 26 '12 at 13:38
2

You cannot do with UserControls. But using ASP.NET ServerControls you can achive it.
Go through this article.
http://devoptions.blogspot.com/2015/02/create-aspnet-server-controls-from.html

Elshan
  • 7,339
  • 4
  • 71
  • 106