A new project was recently started, and almost every page's page_load event needs to be written
Page_load
1 Protected Void Page_load ( Object Sender, eventargs E) {
2If(!This. Ispostback)
3BIND ();
4}
So I thought
Pagebase 1 Public Class Pagebase: system. Web. UI. Page
2 {
3 Protected Void Page_load ( Object Sender, eventargs E) {
4
5If(!This. Ispostback)
6BIND ();
7}
8
9 Protected Void Page_error ( Object Sender, eventargs E) {< br> 10 exception ex = server. getlasterror ();
11 // Exception Handling
12 server. clearerror ();
13 }
14
15 Protected Virtual Void BIND () {}
16 }
17
Then inherit from the pagebase in each page, delete the page_load (Object sender, eventargs e) automatically generated by Vs, and then rewrite the BIND () method:
BIND () 1 Protected Override Void BIND () {
2 Textbox1.text = " Test Cases " ;
3 Throw New Exception ( " Case Error! " );
4 }
5
Run it. The page is normal.