如何写页面基类,其它页面继承该基类
在ASP.NET 2.0中如何写页面继承呀,MASTERPAGE不太好用呀,我想写一个页面基类,在基类中写上共用事件或属性,哪位大哥能帮帮我呀,
------解决方案--------------------我认为 Masterpage+usercontrol 这样的模式开发起来很快重用性也比较高
而且页面上基本只要搭框架做总体布局 一句代码都可以不写
------解决方案--------------------//BasePage.cs
public class BasePage : System.Web.UI.Page
{
private Label lblName;
protected void Page_Load(object sender, EventArgs e)
{
// 自己构造控件布局
lblName = new Label();
lblName.Text = "Hello ";
this.Controls.Add(lblName);
}
}
// ChildPage.aspx
<%@ Page Language= "C# " AutoEventWireup= "true " CodeFile= "ChildPage.aspx.cs " Inherits= "ChildPage " %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN " "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd ">
<html xmlns= "http://www.w3.org/1999/xhtml " >
<head runat= "server ">
<title> 无标题页 </title>
</head>
<body>
<form id= "form1 " runat= "server ">
<div>
</div>
</form>
</body>
</html>
// ChildPage.aspx.cs
public partial class ChildPage : BasePage
{
protected void Page_Load(object sender, EventArgs e)
{
base.Page_Load(sender, e);
}
}
------解决方案--------------------http://www.aspxboy.com/code/default.aspx/S7s2zPJbeI9PJA/OKHpAVwVaUEhf02EgEOgeB3Yd5Z7fLL3ZNgdv7XIqertUOYm9Lt2z7P2vt/2C0IoCxyIplmfUKQlJPOldR5ceRTU2o3gSyBkSkCVWTfC1xE+P4I3aKXE1rn+Qf52TzAOG38pxsQxx3EiqXtpW.Aspx