Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people, just like you, are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
Solved

How do you sharing web forms and code classes across multiple projects in Visual Studio?

Posted on 2004-08-06
7
367 Views
Last Modified: 2008-03-10
Hi.

I am developing multiple websites using ASP.NET in Visual Studio (using Visual Basic).
I have many clients that require a similar web site.  The core structure is the same, as well as most of the code.  However, the websites do have differences, such as image files, CSS files, a vb class that I use to store connection information.  To put it another way, there is a basic core that is shared, with particular variations in a limited number of files.

So here's the problem.  When I change the code of a core component, I want ALL websites to benefit from that enhancement.  So far I only have two websites in ASP.net, but I am converting other sites over from ASP and I may end up with as much as 10-12 websites to maintain.  I would like to not have to maintain 12 separate sites, but leverage the fact that most of the site is shared.

I have tried looking into a single solution with multiple projects, but it seems that a project is pretty much a stand-alone application, and that project files can't be used for other projects (I think).

I have also looked into deployment projects that could specify which files are part of a particular application.  But there are two disadvantages that I think would exist here:
1. I don't host my own sites and I don't have administrator priveleges on the web server (documentation states that I need this for web deployment setup).
2. I'm not sure how I would be able to develop and view one particular website without deploying it.

Any help that would get me going in the right direction would be appreciated.

0
Comment
Question by:Bconner26
  • 3
  • 2
  • 2
7 Comments
 
LVL 17

Accepted Solution

by:
AerosSaga earned 250 total points
ID: 11736690
Classes from projectX are available if you reference the projectX in projectY.  That is I have a site that requires Payment gateway processing, and shipping calculation.  So what I do is I have a moduler solution called shipping for example.  I just copy the entire solution into the new project, and add a reference to that project.  Then any public classes that I need from the shipping solution are available to me in my site by initiating a new instance of the class and then passing the paramaters to the class for the manipulation.  If you have any further questions, just ask as I know that was probably not the most concise explination.

Regards,

Aeros

0
 
LVL 15

Assisted Solution

by:Thogek
Thogek earned 250 total points
ID: 11737105
To put it another way (but basically the same as what AerosSaga is saying)....
Files/classes/etc for a given project can be used by any other projects within the same solution -- with the exception of ASCX and ASPX files.  The using project just has to add the used project as a project reference, and be sure to get the namespaces correct (if they're different) when referencing classes from the used project.  So you should be able to abstract most/all of your common logic into classes and components that can be shared by all Web projects and placing those items into their own project, and then include that project into each of the Web application project's solutions (or just load 'em all into one solution; whichever's easier for you to manage).
0
 

Author Comment

by:Bconner26
ID: 11738394
Thanks for the ideas concerning classes.  This will be useful to share that across projects.

However, the majority of the websites I deal with are made up of ASPX files.  This is what most of them share (both the HTML part and the code behind them).  Is there any way to share those files across projects in the way I described in the question?
0
Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

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.

 
LVL 15

Expert Comment

by:Thogek
ID: 11739582
ASPX files?  I don't think so.

You may want to look into creating your own custom controls (not ASCXs) to encapsulate the reusable HTML about which you are concerned.  This loses the ability to work on the control's own HTML structure with a nice design surface for these controls (as the HTML would typically then be generated by code in a Render method), but gains the ability to be reusable across multiple projects.  (Much like the built-in ASP.NET controls such as DropDownLists, etc.)

See, e.g., http://msdn.microsoft.com/library/en-us/cpguide/html/cpconwalkthroughdevelopingsimplewebformscontrol.asp
0
 
LVL 17

Expert Comment

by:AerosSaga
ID: 11740046
Correct me if I'm wrong Thogek; by creating .ascx controls with the content one can gain access to the controls like so:

Dim x1 As myCustomControl = DirectCast(Me.FindControl("ReportMenu1"), myCustomControl)
                myPageLabel.text = x.MyCustomControl.Label.Text

Public ReadOnly Property GetMyLabelText() As String
 Get
   If Not Label1 Is Nothing Then Return Label1.TexT
 End Get
End Property

Regards,

Aeros
0
 
LVL 15

Expert Comment

by:Thogek
ID: 11740102
That gains you programmatic access to the control once it's on the page, yes.  That's a little different from being able to reuse ASCX files across projects.

Some other references:
http://msdn.microsoft.com/library/en-us/vbcon/html/vbconwebusercontrolsvscustomwebcontrols.asp
0
 

Author Comment

by:Bconner26
ID: 11852163
Thanks for your help.  I'll split the points.  I was able to create a project that contained classes to share across projects.  So the more code I put in classes, the more can be shared.  I'm not quite at the level of custom controls, but I'll try that sometime.
0

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering 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

I recently went through the process of creating a Calendar Control of events with the basis of using a database to keep track of the dates that are selectable, one requirement was to have the selected date pop-up in a simple lightbox.  At first this…
Introduction This article shows how to use the open source plupload control to upload multiple images. The images are resized on the client side before uploading and the upload is done in chunks. Background I had to provide a way for user…
This video shows how to quickly and easily add an email signature for all users on Exchange 2016. The resulting signature is applied on a server level by Exchange Online. The email signature template has been downloaded from: www.mail-signatures…
In a recent question (https://www.experts-exchange.com/questions/29004105/Run-AutoHotkey-script-directly-from-Notepad.html) here at Experts Exchange, a member asked how to run an AutoHotkey script (.AHK) directly from Notepad++ (aka NPP). This video…

789 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