Share User Controls Between Multiple projects

G

Guest

We have a web application with at least 570 Pages and 10's of user controls
....all under project name LinkDevProject ...recently we start separating the
project into multiple projects ....the problem we have in user controls how
to share them without duplicate the control in each project ....we need to
remain the controls in main project and all subproject use them .....what is
the avaiable technique to achieve this?
 
K

Klaus H. Probst

Put the controls in their own assembly and use that in the other projects.
 
B

Brock Allen

Usercontrols aren't really designed to be shared. If you want to have reuse
then the approach is to write a class that derives from Control or WebControl.
This means the control is all in code (no ASCX or designer support) and is
compiled into an assembly (DLL). This is the primary reuse approach. Here
are the quickstarts for that:

http://samples.gotdotnet.com/QuickS.../quickstart/aspplus/doc/webctrlauthoring.aspx

The other approach is a bit of a hack, but you can share ASCX files across
IIS applications by mapping a virtual directory under each of your app folders
to the directory that contains all of your ASCX files. If they use codebehind
then you'll have to copy that assembly to all the apps' ~/bin direcotry.
 
K

Klaus H. Probst

Put the controls in their own assembly, how is that?

Well, if you're using standard UserControl-derived (ASCX) controls that
won't help you, sorry. However it is possible to create a separate assembly
with classes that derive directly from WebControl or Control (or even
TemplateControl though that's less common) and then add a reference to that
assembly in your other projects.
 

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,755
Messages
2,569,534
Members
45,008
Latest member
Rahul737

Latest Threads

Top