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://bbs.csdn.net/topics/390482363? Ticket = ST-704066-MoolZ4f7GW3lTwMCb6cK-passport.csdn.net
Cause:
The subclass Page_Load overwrites the Page_Load method of the parent class.
Solution:
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.