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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T01:34:10+00:00 2026-06-02T01:34:10+00:00

I have a base control: public partial class BaseControl : System.Web.UI.UserControl { protected virtual

  • 0

I have a base control:

public partial class BaseControl : System.Web.UI.UserControl
{
    protected virtual void Page_Load(object sender, EventArgs e)
    {
    }

    protected override void OnInit(EventArgs e)
    {
        base.OnInit(e);
        Page.LoadComplete += Page_LoadComplete;
    }

    protected virtual void Page_LoadComplete(object sender, EventArgs e)
    {
        Page.LoadComplete -= Page_LoadComplete;
    }
}

I then have a control that derives from this

public partial class MyChildControl : BaseControl

The problem I have is that if I load MyChildControl more than once then I get an object ref error on Page.LoadComplete -= Page_LoadComplete; in BaseControl. I sort of understand why but I have 2 questions:

  1. Shouldn’t each MyChildControl reference it’s own version of BaseControl which in turn registers it’s own PageLoadComplete?
  2. How can I check to see if it is not null? I can’t seem to do != null.

EDIT: It seems that Page is null and checking Page != null resolves the issue but I still don’t understand how Page is null.

  • 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-02T01:34:12+00:00Added an answer on June 2, 2026 at 1:34 am

    Page_LoadComplete can’t be null, it’s just a delegate created for methog Page_LoadComplete. So i think Page in Page.LoadComplete may be null or page has custom logic for adding handler to event LoadComplete and has ref error there

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

Sidebar

Related Questions

I have a base user control (inherited from System.Web.UI.UserControl ) public delegate void MyEventHandler(object
I have a user control as such: public partial class MyControl : UserControl {
I have a custom base user control in silverlight. <UserControl x:Class=Problemo.MyBaseControl xmlns=http://schemas.microsoft.com/winfx/2006/xaml/presentation xmlns:x=http://schemas.microsoft.com/winfx/2006/xaml xmlns:d=http://schemas.microsoft.com/expression/blend/2008
I created a generic base class for a WinForm UserControl: public partial class BaseUserControl<T>
I have a control that is created like so: public partial class MYControl :
I have a class like the following: public class DropDownControl<T, Key, Value> : BaseControl
I have 2 web user controls, both inherit the same base class which extends
Lets say we have a derivided class SerializableLabel from the base class System.Windows.Controls. [XmlRoot(SerializableLabel)]
I have 2 custom controls as defined below: public class Icon : Control {
I have a question about extending a custom control which inherits from UserControl. public

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.