------------------ Network Abstract ----------------
1. Create basepage. CS to inherit from the page class.
1 protected Void page_load (Object sender, system. eventargs E)
2 {
3 If (! Ispostback)
4 {
5 String name = Strid; // context. User. Identity. Name;
6 Email. Text = databasegateway. retrieveaddress (name );
7 sitename. Text = "Microsoft-site ";
8 // Define the pageload event
9 Pageloadevent (sender, e );
10}
11}
2.CodeHidden class inherited from basepage
1 Public Class main: basepage
2 {
3 Protected system. Web. UI. webcontrols. hyperlink hyperlink1;
4 Protected system. Web. UI. webcontrols. Label pagenumber;
5 // Overwrite the pageload event of baepage
6 Protected Override Void pageloadevent (Object sender, system. eventargs E)
7 {
8Pagenumber. Text = "Page 1 ";
9}
10 }
Application: The basepage page can write a lot of repetitive content, such as common page verification information.
/// <Summary>
/// Summary of pagebase
/// </Summary>
Public class pagebase: system. Web. UI. Page
{
Public pagebase ()
{
//
// Todo: add the constructor logic here
//
This. init + = new eventhandler (pagebase_init );
}
Private void pagebase_init (Object sender, eventargs E)
{
If (session ["username"] = NULL | session ["password"] = NULL)
{
This. response. Redirect ("~ /Web/loginpage. aspx ");
}
Else
{
String strusername = session ["username"]. tostring ();
String struserpad = session ["password"]. tostring ();
If (! Commonmethod. haveauthority (strusername, struserpad, this. Request. Path. tostring ()))
{
This. response. Redirect ("~ /Web/loginpage. aspx ");
}
}
}
}