Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7754543
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T12:20:09+00:00 2026-06-01T12:20:09+00:00

Is it possible to load a User Control that was registered in the web.config

  • 0

Is it possible to load a User Control that was registered in the web.config file, rather than in the aspx file?

Here is an example of what I would do. In my aspx:

index.aspx

<%@ Register TagPrefix="module" TagName="ModExample" Src="~/controls/example.ascx" %>

index.cs

protected void Page_Load(object sender, EventArgs e)
{
    controls_example exmp = LoadContent("controls/example.ascx") as controls_example;
    myContentPanel.Controls.Add(exmp);
}

I had to register my user control in the page, or else ASP would not know what “controls_example” was. However, I know you can change your web.config to look like this:

<configuration>
    <system.web>
        <pages>
            <controls>
                <add tagPrefix="module" tagName="ModExample" src="~/controls/contentModule.ascx"/>
                <add assembly="Subtext.Web.Controls" namespace="Subtext.Web.Controls" tagPrefix="module"/>
            </controls>
        </pages>
    </system.web>
</configuration>

So, here is the problem. How do I create a variable of type “controls_example” when it has been registered in the web.config file?

Do I need to:

  • add a “using namespace”?
  • change/add something in my web.config?
  • not define what the datatype of the variable is? (I would love to avoid this)
  • something else?
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-01T12:20:10+00:00Added an answer on June 1, 2026 at 12:20 pm

    Your web.config looks fine. In the page you need to add a using with the namespace of your control. Then you can use the page’s LoadControl method to get an instance of your control that you can then add as a child control to some container (I usually choose a asp:Placeholder to ensure its position is where I want it)

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I was wondering if it was possible to load a asp.net control (.ascx) that
I load a user control in a web page which throws an exception: this.LoadControl(someusercontrol);
I have a user control on a web form that is declared as follows:
I wonder if it's possible to load jQuery within Opera User JavaScript , so
Is it possible to load new lines from a text file to variables in
I'm creating a comments web user control. I want to use this comments control
I have created a web user control called Activity. I have defined a public-facing
First, I'm really new to Asp.Net Ajax I got an user control that have
In my code I load a user control (uc) in the page_load event. The
Please advise me. Winforms app, C#. I have a user control (UC) that contains

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.