How to include ascx into dll or reference multiple user controls in web.config?

Posted on 2008-10-22
Last Modified: 2010-08-05
Hello Expert!

Here is my point. I've a Projet Class Library who have 21 user controls with code behind file
ex: usercontrol1.ascx, usercontrol1.cs....

How can i include the ascx content into the dll file?

What i need is a easy way to use my usercontrol in different pages without register in the page.

When I try to add "controls" into the "<pages><controls>" in the web.config i got a error. I guest it's because i can't specify the "src" wheres the ascx are located.

I know i can manually add controls 1 by 1 on the page controls element in web.config.

But is there any way to add a "Global Reference"?

Projet namespace and assambly: mynamespace.customctrl



<%@ Control Language="C#" AutoEventWireup="true" Inherits="mynamespace.customctrl.ctrlone,mynamespace.customctrl " %>

<asp:Button ID="Button1" runat="server" Text="Button" />



namespace mynamespace.customctrl


    public class ctrlone : System.Web.UI.UserControl


        protected Button Button1;

        protected override void OnLoad(EventArgs e)



            Button1.Text = "Custom text";            






<customctrl:ctrlone ID="ctrl1" runat="server" />





     <add tagPrefix="customctrl" namespace="mynamespace.customctrl" assembly="mynamespace.customctrl"/>



Open in new window

Question by:jabcoco
  • 2
  • 2

Expert Comment

ID: 22785842
You have to regesiter the user controls in the page that's it's being used in that is the way the framework works. Sorry
LVL 10

Author Comment

ID: 22787735
OK, or maybe registring all controls individualy in pages/controls using this patern in web.config
<add tagPrefix="customctrl" tagName="ctrlone" src="~/MyUserControls/usercontrol.ascx" />


Accepted Solution

WanaBRich earned 500 total points
ID: 22790702
Yes that should work. might be of some help

LVL 10

Author Closing Comment

ID: 31509046
Thanks :)

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Server error in 'XXXXXXXX' application. 12 69
Need an intro to -- .Net SQL Authorization Manager 7 77
Replace &lt; with < 14 55
Need a starter for ETL protocol? 4 42
A quick way to get a menu to work on our website, is using the Menu control and assign it to a web.sitemap using SiteMapDataSource. Example of web.sitemap file: (CODE) Sample code to add to the page menu: (CODE) Running the application, we wi…
International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
This Micro Tutorial will give you a basic overview how to record your screen with Microsoft Expression Encoder. This program is still free and open for the public to download. This will be demonstrated using Microsoft Expression Encoder 4.
Both in life and business – not all partnerships are created equal. As the demand for cloud services increases, so do the number of self-proclaimed cloud partners. Asking the right questions up front in the partnership, will enable both parties …

910 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

Need Help in Real-Time?

Connect with top rated Experts

21 Experts available now in Live!

Get 1:1 Help Now