views:

34

answers:

3

Hi
We have two asp.net sites (based on episerver).
Using Telerik Asp.net controls.
We have some funtionality that we want to have availible in both sites.
Right now one of the sites use webparts/usercontrols and the other uses usercontrols.

Is there any way to share the functionality between these sites?
What I would like is to be able to share usercontrols between the sites.

/Jimmy

+2  A: 

Start a new class library project, reference that project in both your site projects, then pull out the common controls and code into the library project.

Ycros
But that doesn't include ascx files right?
Jimmy Engtröm
+3  A: 

Since your talking about user controls I'm assuming you also have .ascx files that are part of the user controls, which makes this tricky.

I guess the ideal solution would be to move everything into server controls, that way you could just reference the assembly, but if you are inheriting from other controls that utilize .ascx files, your kinda stuck with them.

One way of handling it is to use the file linking capabilities in Visual Studio (Add Existing File, click the down arrow, choose link option) to share the same physical file between projects within the same solution. This is not ideal simply because you have to make sure that the ascx files are copied to both sites prior to deployment (I've done it with a post-build script before), but there is a lot that can still be pretty fragile.

Another option that is more technically complex, but probably a "better" way of handling it would be to use a Virtual Path Provider to do the work for you. Here is an article which talks about using Virtual Path Providers to do the sort of thing you are wanting to do.

ckramer
Yepp I have ascx files I'll look into the links you suggested.I did know about the server control option but I rather have the ascx files intact.Thanks
Jimmy Engtröm
A: 

Like mentioned you could put the files in a VPP directory in the live environment and that way only have to copy ASCX-files to one folder for a two-site-code-infront-update. Code-behind updates would need the DLL built and overwritten for both sites though.

If you are using SVN in your development environment you could also setup a svn:external linked folder from one of the projects and that way only have the code and it's revision history in one repository.

Johan Kronberg