Solved

Whats the best way to share custom user controls accross mulitple websites / projects

Posted on 2009-07-09
1
193 Views
Last Modified: 2012-05-07
I'm sure theres a simple solution to this, however i'm looking to create a series of controls, all of which can be reused across multiple projects.

The idea is that when i make an improvement to a control,  every other project that shares the control will also see the benefits.

Now Im curious on how i handle html, images, styles etc i.e. should this be present on the projects referencing this control project?

And also whats the best way to implement this from a code standards point of view?

This is quite general i admit - but any advice would be greatly appreciated, along with any working examples, as thats how i tend to understand concepts better?

Thanks
Paul
0
Comment
Question by:paulCardiff
1 Comment
 
LVL 6

Accepted Solution

by:
ahmad2121 earned 500 total points
ID: 24816267
There are two ways:

1. Create a Web Deployement Project

Download for vs 2008:  http://www.microsoft.com/downloads/details.aspx?familyId=0AA30AE8-C73B-4BDD-BB1B-FE697256C459&displaylang=en

How to set them up and use them: http://www.codedigest.com/Articles/VisualStudio/126_Web_Deployment_Project_for_Visual_Studio_2005_and_2008.aspx

2. Build a regular Web Project, compile it, then use that DLL as a reference (same thing as above basically)

Dealing with HTML and images is pretty easy, For those you could include them in your Web [Deployement] Project as embedded resources, then you can configure them as web resources

Here are instructions on how to set this up:

http://aspnet.4guysfromrolla.com/articles/080906-1.aspx

The benefits of this are:

1. ASP.NET code is precompiled, so you will never have syntax issues
2. Once the DLL for the project is built, you can use it with any project. The WDP is not automatically set as a reference if you include the outputted DLL only, but you can force it as a dependencies for your other projects to make sure it gets compiled first
3. Syntax to use it is very very easy

The downsides:

1. slows down your build time a lot (asp.net code compiles much more slowly)
2. quite a bit of setup involved initially, but once its working its a beauty
3. one other one I forgot, but it can't be that bad :)

Regarding better coding standards, stick to the usual ones. In the end you are going to have a library and you can use that however which way. Figure out what your namespaces will look like, draw it out, draw your dependency lines etc. And as always, when creating libraries, you want to minimize it's dependencies on other modules, and never ever have cyclic dependencies. If a function or a class can be moved to that library, move it rather than including another reference.

Thats pretty much it. Happy coding!
0

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article discusses the ASP.NET AJAX ModalPopupExtender control. In this article we will show how to use the ModalPopupExtender control, how to display/show/call the ASP.NET AJAX ModalPopupExtender control from javascript, how to show/display/cal…
In this Article, I will provide a few tips in problem and solution manner. Opening an ASPX page in Visual studio 2003 is very slow. To make it fast, please do follow below steps:   Open the Solution/Project. Right click the ASPX file to b…
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …

820 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question