Share User Controls Between Multiple projects

  • Thread starter Thread starter Guest
  • Start date Start date
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?
 
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.

-Brock
DevelopMentor
http://staff.develop.com/ballen
 
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.
 
Back
Top