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 1035239
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T14:30:49+00:00 2026-05-16T14:30:49+00:00

TL;DR: All controls within a usercontrol that’s being used outside it’s home project are

  • 0

TL;DR: All controls within a usercontrol that’s being used outside it’s home project are null when that usercontrol’s Page_Init/Page_Load methods are called.

The setup is like this:

Projects “UI.Frontend”, “UI.ControlPanel”, and “UI.Common” are “ASP.NET Web Application”s. UI.Common is never meant to be accessed directly- it just contains UserControls that are needed in both the frontend and the control panel.

So, an aspx file (SomeFrontendPage.aspx) in UI.Frontend contains the lines:

<%@ Register tagprefix="BP" Namespace="UI.Common" Assembly="UI.Common" %>

and later:

<BP:MyControl runat="server" ID="ctlMyControl" />

while over in UI.Common, there’s a control named MyControl (normal ascx, ascx.cs, and ascx.designer.cs files). Now, when I open SomeFrontendPage.aspx in a browser, ctlMyControl gets loaded and it’s init+load methods get executed. The problem is all subcontrols of MyControl never get initialized. Example (if MyControl.ascx has a textfield of ID txtBlah):

    protected void Page_Init(object sender, EventArgs e)
    {
        txtBlah.Text = "test";
    }

The above code will run, but will cause a null pointer (well, “Object reference not set to an instance of an object”) since txtBlah will be null.

Edit:
An example control would be:

<%@ Control Language="C#" AutoEventWireup="true" CodeBehind="MyControl.ascx.cs" Inherits="Common.MyControl" %>
Whatever: <asp:TextBox ID="txtWhatever" runat="server"  />
  • 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-05-16T14:30:50+00:00Added an answer on May 16, 2026 at 2:30 pm

    You may find you have more problems that what is immediately shown. ASCX files aren’t embedded in assemblies by default, and when they are, you then need to create a virtual path provider to access them.

    Can we see an example control?

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

Sidebar

Related Questions

Can someone tell me how I can disable all controls within a div? The
is there a way on android to collect all of the controls within an
I have heard that GTK covers all controls so that developers do not care
I am trying to make something that will enable all controls if a SubString
Does anybody have a good way of finding ALL the controls within an object
Good afternoon all Here is my scenario: I have user controls within a master
When I set my tab item font weight to bold, all the controls within
My UserControl is a kind of a container that has a set of controls
I'm having an issue referencing public procedures of User Controls that I've created within
I have a usercontrol that acts as a container to hold more usercontrols within

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.