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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T14:00:00+00:00 2026-05-15T14:00:00+00:00

I have a class named PageBase inheriting from ASP.NET Page . I want to

  • 0

I have a class named PageBase inheriting from ASP.NET Page. I want to do something in PageBase‘s Page_Load. All pages in my application have their logic done on their Page_Load.
I’m thinking of a way that Page_Load of both of PageBase and other pages run without having to override Page_Load in pages. Is it possbile?

  • 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-15T14:00:01+00:00Added an answer on May 15, 2026 at 2:00 pm

    Yes, it’s possible. Just attach the Page_Load handler within constructor. This is how you do it.

    /// <summary>
    /// Your PageBase class.
    /// </summary>
    public class PageBase : System.Web.UI.Page
    {
        /// <summary>
        /// Initializes a new instance of the Page class.
        /// </summary>
        public Page()
        {
            this.Load += new EventHandler(this.Page_Load);
        }
    
        /// <summary>
        /// Your Page Load
        /// </summary>
        /// <param name="sender">sender as object</param>
        /// <param name="e">Event arguments</param>
        private void Page_Load(object sender, EventArgs e)
        {
            try
            {
            }
            catch
            {
                 //handle the situation gracefully.
            }
        }
    }
    

    EDIT

    Here’s how it works.

    Load is a public event declared in System.Web.UI.Page which is inherited in the PageBase class as it is. Since this is an event you can attach as many as handler on the event, each of them will be called/executed whenever the Load event is raised. In the PageBase class we are attaching an event-handler routine to the Load event. This is better way to do it instead of inheriting the OnLoad protected routine where you need to explicitly call the base version. When the actual Page object is created/instantiated the base class object is created first then the sub-class is instantiated, so when the PageBase object is constructed the event-handler is attached onto the Load event which will be called whenever the Page object fires the Load event.

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

Sidebar

Related Questions

I have a class named CropImageView which is extended from ImageView . but the
I have a Class named Question and a related Class named Answers. I want
I have a class named baseClass. From this class I inherit a class names
I have a Class named Constants that contains all the constant variable in my
I have a multiple web sits asp.net application. In this application different domains using
I have a class named MyClass and I want this class to extend Graphics2D
I have class named CiF and I want to move in the constructor pointer
I have class named worker , I want to create new instance of this
I have a class named fdetails and I do not want any other class
I want to have a class named ProjectDirectory and a class named MetaDirectory .

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.