1.先建立BasePage.cs,继承自Page类
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 //定义PageLoad事件
9 PageLoadEvent(sender, e);
10 }
11 }
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 //定义PageLoad事件
9 PageLoadEvent(sender, e);
10 }
11 }
2.页面的代码隐藏类继承自BasePage
1public class Main :BasePage
2 {
3 protected System.Web.UI.WebControls.HyperLink HyperLink1;
4 protected System.Web.UI.WebControls.Label pageNumber;
5 //覆写BaePage的PageLoad事件
6 protected override void PageLoadEvent(object sender, System.EventArgs e)
7 {
8 pageNumber.Text = "第一页";
9 }
10}
2 {
3 protected System.Web.UI.WebControls.HyperLink HyperLink1;
4 protected System.Web.UI.WebControls.Label pageNumber;
5 //覆写BaePage的PageLoad事件
6 protected override void PageLoadEvent(object sender, System.EventArgs e)
7 {
8 pageNumber.Text = "第一页";
9 }
10}