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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T11:58:58+00:00 2026-06-08T11:58:58+00:00

Suppose I have a web project and a bunch of different Web Forms, effectively

  • 0

Suppose I have a web project and a bunch of different Web Forms, effectively all different classes inheriting System.Web.UI.Page.

I decided it’d be great to have some fields, methods, and a few things to happen in the Page_Load method of any page I use in my project.

Off the cuff, I thought perhaps to make a class, say MasterPage, that has all the fields and methods I want (with protected level) and have this class inherit System.Web.UI.Page.

Then every page in my project should now inherit from MasterPage instead of System.Web.UI.Page.

While this worked, there were a couple problems with it.

  1. I couldn’t really “catch” forms that were still inheriting from System.Web.UI.Page very easily. Is there an easy way?

  2. Due to the way it was setup, the MasterPage’s PageLoad is virtual and has to be overridden e.g.:

    protected override void Page_Load(object sender, EventArgs e)
    {
        base.Page_Load(sender, e);
        // rest of stuff for this page...
    }
    

    Is there any easier way to have the parent’s method always called first without explicitly putting in the base call in every page?

  • 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-08T11:59:00+00:00Added an answer on June 8, 2026 at 11:59 am
    1. Find/replace is your friend.
    2. Don’t override an event handler in the inheriting class. Instead, make the base handler private and create new handlers in your inheriting class. Or, override OnInit() in your base class so you don’t have to worry about which Page_Load was called first.

    Another completely different solution is to use ASP.NET Master Pages. This is usually the best way to share content across all pages in a web application.

    Master pages provide functionality that developers have traditionally
    created by copying existing code, text, and control elements
    repeatedly; using framesets; using include files for common elements;
    using ASP.NET user controls; and so on.

    Master page resulting page composition

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

Sidebar

Related Questions

Suppose I have 2 web services A and B in SOA project. Both web
In my web project, I am using Static List. So say suppose I have
Suppose I have a web application, which uses jQuery for Ajax and UI. Now
The setup is suppose I have 2 memcached servers, and 2 web servers to
Suppose that you have a big Data Entry Web Application Like Microsoft CRM ,
Lets suppose that I have some pages some.web/articles/details/5 some.web/users/info/bob some.web/foo/bar/7 that can call a
Suppose I have WCF web service that that can retrieve collection of <Person> objects.
Suppose you have two seperate ASP.NET Web Application projects that both need to use
If I have this project structure Foo.Data reference EntityFramework Foo.Business reference Foo.Data Foo.Web reference
I have been assigned a project to develop a set of classes that act

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.