views:

327

answers:

3

I have a set of UserControls in a ASP.NET website that I would like to share to multiple website. But it seems we are unable to create a class library with UserControls in it with the ascx file. While MSDN suggest building a Web Control, I Would rather find a way to share the existent controls instead of destroying them to create new web controls.

Is there any way of creating a library of UserControls?

Thanks

+6  A: 

Here is one way of doing it:

Creating and Using User Control Libraries.

Andrew Hare
I've done something similar to this, except with the added step of using the web deploy wizard to compile all the code into a DLL that can be loaded by the consumer. Same principle though.
Marc
+1  A: 

You can't compile them into a project per se. You can get something close to this by linking the files into the project so there is one master version of the file but each project also has its own copy. You can either:

  • Using a source control share function to have one location and share it into the other projects
  • Create one project for the controls and then link them into other project by using "Add Existing Item", clicking the little arrow next to the Add button, and selecting "Add As Link".
Chris Hynes
+2  A: 

You should use instead a Composite control. Here is a comparison between web user controls and composite controls:

http://msdn.microsoft.com/en-us/library/aa719735(VS.71).aspx

Igor Zelaya