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

  • Home
  • SEARCH
  • 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 6876249
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T04:27:13+00:00 2026-05-27T04:27:13+00:00

My asp.net application has a custom base user control that is inherited from other

  • 0

My asp.net application has a custom base user control that is inherited from other user controls. This custom base user control has three properties that have been made public. When the user control is loaded the custom base user control properties are null. I am trying to figure what I am doing wrong. can someone please help figure out what step I am missing?

custom base user control loading code from parent page:

    private void Render_Modules()
    {
        foreach (OnlineSystemPageCustom.OnlineSystemPageHdr.OnlineSystemPageModule item in custompage.Header.Modules)
        {
            if (item.ModuleCustomOrder != 99)
            {
                webonlinecustombase ctl = (webonlinecustombase)Page.LoadControl("../IPAM_Controls/webtemplatecontrols/webonlinecustombase.ascx");
                ctl.Event = Event;
                ctl.custompage = custompage;
                ctl.custommodule = item;
                this.eventprogrammodules.Controls.Add(ctl);
            }
        }
    }

custom base user control code behind

public partial class webonlinecustombase : System.Web.UI.UserControl
{
    public Event Event { get; set; }
    public OnlineSystemPageCustom custompage { get; set; }
    public OnlineSystemPageCustom.OnlineSystemPageHdr.OnlineSystemPageModule custommodule { get; set; }

    public void Page_Load(object sender, EventArgs e)
    {
        string typeName = custommodule.ModuleInternetFile;
        inpagelink.HRef = "#" + custommodule.ModuleName.Replace(" ", "").Replace("/", "");
        modtitle.InnerText = custommodule.ModuleName;
        Type child = Type.GetType(typeName);

        UserControl ctl = (UserControl)Page.LoadControl(child, null);
        if (ctl != null)
        {
            this.modsection.Controls.Add(ctl);
        }
    }
}

sample code of user control inheriting base user control

public partial class eventscientificoverview : webonlinecustombase
{
    protected void Page_Load(object sender, EventArgs e)
    {
        if (custommodule.ModuleDefaultVerbiage != null && custommodule.ModuleDefaultVerbiage != "") { this.Load_Verbiage(false); }
        else if (custommodule.ModuleCustomVerbiage != null && custommodule.ModuleCustomVerbiage != "") { this.Load_Verbiage(true); }
    }

    protected void Load_Verbiage(bool usecustom)
    {
        if (usecustom) { this.scientificoverviewverbiage.InnerHtml = custommodule.ModuleCustomVerbiage; }
        else { this.scientificoverviewverbiage.InnerHtml = custommodule.ModuleDefaultVerbiage; }
    }
}
  • 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-27T04:27:14+00:00Added an answer on May 27, 2026 at 4:27 am

    You must call Render_Modules in the init event of the parent page.

    Also, you may want to restructure your base/custom classes to avoid event execution order confusion since the load event will be fired in both the base and the custom classes.

    Any time we have this type of structure, we always implement an OnLoad method in the base class for inheritors to override. This way we can control exactly when the Load logic is executed in the inheritors.

    Updated with additional info

    Here is some additional information on how to handle the load events in base and child classes.

    In webonlinecustombase, add the following:

    protected virtual void OnPageLoad() {
    }
    

    then modify your page load event to call this new method at the appropriate time:

    public void Page_Load(object sender, EventArgs e)
    {
        string typeName = custommodule.ModuleInternetFile;
        inpagelink.HRef = "#" + custommodule.ModuleName.Replace(" ", "").Replace("/", "");
        modtitle.InnerText = custommodule.ModuleName;
        Type child = Type.GetType(typeName);
    
        UserControl ctl = (UserControl)Page.LoadControl(child, null);
        if (ctl != null)
        {
            this.modsection.Controls.Add(ctl);
        }
    
        // Now let the inheritors execute their code
        OnPageLoad();
    }
    

    then, in your inherited class, change:

    protected void Page_Load(object sender, EventArgs e)
    

    to

    protected override void OnPageLoad()
    

    As I was reviewing this code, I discovered that you are also dynamically loading controls in webonlinecustombase. You will need to move the loading of the controls into the init event in order for them to work correctly in the standard page logic.

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

Sidebar

Related Questions

I have a ASP.NET intranet application that has a document library section. The user
Other than the fact that ASP.NET MVC Web Application has more clarity in its
I have a GridView control in an Asp.net application, that has a <asp:buttonField> of
I have a major problem. We have a asp.net application that has this report
I have an ASP.NET MVC application that has one part where I dont really
I am creating an ASP.NET MVC application that has postcode lookup functionality. I capture
The ASP.NET application that I am currently responsible for at my day job has
My base controller has this override: protected override void OnException(ExceptionContext filterContext) { // http://forums.asp.net/t/1318736.aspx
I'm developing an asp.net application that has some potentially large data tables. I would
I have an ASP.NET MVC web application that implements a custom membership provider. The

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.