Inheritance of System. Web. UI. Page in ASP. NET,

Source: Internet
Author: User

Inheritance of System. Web. UI. Page in ASP. NET,

I have read some articles. By writing PageBase pages and inheriting other pages to this PageBase, you can easily implement user inspection and other requirements.

Later, we found that the PageLoad of the parent class is not executed after the subclass page is inherited.

The following Post raises a question, but does not provide a positive solution:

Http:// Ticket =


The subclass Page_Load overwrites the Page_Load method of the parent class.


Add "new" to the front of the subclass method, and write it in the subclass method as follows:

Public partial class NewPage: Pagebase

Protected new void Page_Load (object sender, EventArgs e)
// The Page_Load of the parent class is overwritten, so you need to call it manually

Base. Page_Load (sender, e );



In this way, the PageLoad method of the parent class and subclass will be called, and you can control whether the PageLoad of the parent class is called first, so that the user's identity can be checked first.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.