How to share user control between multiple websites

M

moondaddy

I'm using asp.net 2.0 and c# and would like to share some user control
between several websites. these websites are on the same server and have a
physical location right next to each other like this:

D:\Websites\Website1
D:\Websites\Website2

I'm thinking of putting the controls for sharing in a common directory like
this:
D:\Websites\CommonControls

What's the recommened way to do this and are there any special
conciderations to keep in mind?

FYI: These shared controls will be accessing databases and reading/writing
images to the directory.


Thanks
 
G

Guest

I'm using asp.net 2.0 and c# and would like to share some user control
between several websites. these websites are on the same server and have a
physical location right next to each other like this:

D:\Websites\Website1
D:\Websites\Website2

I'm thinking of putting the controls for sharing in a common directory like
this:
D:\Websites\CommonControls

What's the recommened way to do this and are there any special
conciderations to keep in mind?

Consider to build a Class Library or Web Control Library.
http://www.codeguru.com/csharp/.net/net_asp/webforms/article.php/c12725/
 
M

moondaddy

Thanks for your replies.

These user controls are more like content pages rather than a specific type
of control with functionality like a grid or something. in many cases they
just have static text. I have 2 websites that could share some common
content (webforms, html pages, or user controls). I thought it would be
easier to maintain the content (update the text from time to time) if it
were in one place rather than redundantly placed in each site.

does this change your advice?
 
M

Mark Rae

These user controls are more like content pages rather than a specific
type of control with functionality like a grid or something. in many
cases they just have static text. I have 2 websites that could share some
common content (webforms, html pages, or user controls). I thought it
would be easier to maintain the content (update the text from time to
time) if it were in one place rather than redundantly placed in each site.

does this change your advice?

Not at all, though a full-blown web control library might be a bit overkill
if we're talking only of a few small files...

Another way would be to use a product such as Microsoft Visual SourceSafe...
Apart from the source control functionality (which every serious developer
should be using anyway...), this allows individual files to be "shared"
across multiple projects. Although a copy of the file does exist separately
in each project, when you update it in one project it gets updated in all
other projects into which it has been shared...

I use this quite a lot for things like individual debugging pages which I
always add to every public internet web app I build...

Depending on which version of Visual Studio.NET you have, you probably
already have a copy of Visual SourceSafe...
 
S

Steven Cheng[MSFT]

Hello Moondaddy,

Naturally, ASP.NET usercontrol(ascx) is not designed for reuse scenario,
just like aspx pages. Scottgu has ever posted a blog article demonstrate
how to make ASP.NET acsc usercontrol and page reusable in multiple projects
in ASP.NET 2.0:

#Building Re-Usable ASP.NET User Control and Page Libraries with VS 2005
http://weblogs.asp.net/scottgu/archive/2005/08/28/423888.aspx

However, such approach has some certain natural limitations due to the
underlying design and implementation of usercontrol. If possible, I would
recommend you consider other means to build those reusable components. Such
as create custom webserver controls, or just define some shared include
files that be used in multiple projects.

Sincerely,

Steven Cheng

Microsoft MSDN Online Support Lead



==================================================

Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/subscriptions/managednewsgroups/default.aspx#notif
ications.



Note: The MSDN Managed Newsgroup support offering is for non-urgent issues
where an initial response from the community or a Microsoft Support
Engineer within 1 business day is acceptable. Please note that each follow
up response may take approximately 2 business days as the support
professional working with you may need further investigation to reach the
most efficient resolution. The offering is not appropriate for situations
that require urgent, real-time or phone-based interactions or complex
project analysis and dump analysis issues. Issues of this nature are best
handled working with a dedicated Microsoft Support Engineer by contacting
Microsoft Customer Support Services (CSS) at
http://msdn.microsoft.com/subscriptions/support/default.aspx.

==================================================



This posting is provided "AS IS" with no warranties, and confers no rights.
 
?

=?ISO-8859-1?Q?G=F6ran_Andersson?=

It doesn't matter where you put the files for the controls or how you
use them, as the two web sites are separate applications, you will
always have a separate instance of the user controls for each application.

If you want to share data between the applications, you have to do it on
a lower level, like creating a windows service that runs on the server
that both applications can communicate with.
 
M

moondaddy

Thanks to all. it sounds like a shared include file would be the way to go.
Can you recommend a resource describing how to use a shared include file in
such a scenario?

Thanks.
 
S

Steven Cheng[MSFT]

Thanks for your reply Moondaddy,

About referencing include template in ASP.NET here are some public article
you can refer to:

#How To Dynamically Include Files in ASP.NET
http://support.microsoft.com/kb/306575

#ASP.NET Page Templates - Using Inheritance
http://www.codeproject.com/aspnet/page_templates.asp

#Using include files with ASP.NET
http://www.christopherjason.com/articles/using-includes-asp-net/

#Simulating include Files with an ASP.NET Server Control
http://msdn2.microsoft.com/en-us/library/aa479009.aspx

Hope this helps.

Sincerely,

Steven Cheng

Microsoft MSDN Online Support Lead


This posting is provided "AS IS" with no warranties, and confers no rights.
 

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

No members online now.

Forum statistics

Threads
473,994
Messages
2,570,223
Members
46,812
Latest member
GracielaWa

Latest Threads

Top