By design, User Controls are inaccessible outside of the application domain in which
they reside.This is for security reasons. However, this can be a limitation if you want to
share User Controls across several applications on a server. A fairly straightforward
workaround exists, which involves setting up a virtual directory within each application
that needs to use the User Controls, and mapping that virtual directory to a single physical
directory containing the User Controls.This solution is better than simply copying
the User Controls from application to application, because that would quickly turn into
a maintenance nightmare.
These steps were developed by readers of AspAlliance.com, and were first published
in the article listed at the end of this section.
1. Create a Web application project to hold the User Controls, and place the shared
User Controls in this project.
2. Create a virtual directory in each application that needs to use these shared User
Controls.This is done in the IIS manager by right-clicking on the application and
choosing New,Virtual Directory. Browse to the folder created for the Web application
in Step 1, and name the directory the same as that folder.
3. Create a reference from each application that needs the shared controls to the
shared controls.This is done in Visual Studio .NET from within the Solution
Explorer by right-clicking and choosing Add Reference. Browse to the bin folder
of the project created in Step 1 and select the DLL from that folder. (It should
have the same name as the project by default.)
4. Drag-and-drop will not work for these shared User Controls in VS.NET. Instead,
you must manually type the <%@ Register %> directive and specify the Src of the
User Control, referring to the virtual directory you set up
Showing posts with label Sharing User Controls. Show all posts
Showing posts with label Sharing User Controls. Show all posts
Subscribe to:
Posts (Atom)
Archives
-
▼
2008
(100)
-
▼
October
(21)
- Change the Permissions Given to ASP.NET Code
- ASP.Net Enabling Web Site Debugging
- ASP.NET Web Service Creation
- ASP.NET Stack Collection
- ASP.NET Queue Collection
- ASP.NETHashTable Collection
- ASP.NET Creating Custom Collection
- How to Declare Collections in ASP.NET
- Load User Controls Programmatically
- Dynamically Render an Image
- Add Controls to Web Form Dynamically
- Perform Selective Input Validation
- Use Forms Authentication
- Using IIS Authentication
- Allow User to Upload File
- Programmatically Set Control Focus
- Pop-Up Window with JavaScript
- Respond to Client-Side Events with JavaScript
- Creating Stateful Page Member Variables
- Storing Information Between Postbacsk
- Redirect the User to Another Page
-
▼
October
(21)