writer.Write(@"</td></tr><tr><td width=''''100%'''' colspan=''''3''''>页脚 </td></tr></table></body></html>");
}
}
上面的PageBase.cs就是我们的自定类,这样,我们在其他ASPX页面中就可以直接继承PageBase这个类,而非System.Web.UI.Page,下面分别是index.aspx和newContact.aspx的代码(分别包含index.aspx.cs和newContact.aspx.cs):
Index.aspx
<%@ Page language="c#" Codebehind="index.aspx.cs" AutoEventWireup="false" Inherits="wab.index" %>
<form id="index" method="post" runat="server">
<asp:DataGrid id="contacts" runat="server" Width="492px" Height="104px"></asp:DataGrid>
</form>
index.aspx.cs(继承自定义类PageBase)
public class index : PageBase
{
protected System.Web.UI.WebControls.DataGrid contacts;
private void Page_Load(object sender, System.EventArgs e)
{
// 在此处放置用户代码以初始化页面
}
#region Web Form Designer generated code
override protected void OnInit(EventArgs e)
{
//
// CODEGEN:该调用是 ASP.NET Web 窗体设计器所必需的。
//
InitializeComponent();
base.OnInit(e);
}
/// <summary>
/// 设计器支持所需的方法 - 不要使用代码编辑器修改
/// 此方法的内容。
/// </summary>
private void InitializeComponent()
{
this.Load += new System.EventHandler(this.Page_Load);
}
#endregion
}
newContact.aspx
<%@ Page language="c#" Codebehind="newContact.aspx.cs" AutoEventWireup="false" Inherits="wab.newContact" %>
<form id="newContact" method="post" runat="server">
<P><FONT face="宋体">名子</FONT>
<asp:TextBox id="TextBox1" runat="server"></asp:TextBox></P>
<P><FONT face="宋体">姓氏</FONT>
<asp:TextBox id="TextBox2" runat="server"></asp:TextBox></P>
<P>
<asp:Button id="Button1" runat="server" Text="Button"></asp:Button></P>
</form>
newContact.aspx.cs(继承自定类PageBase)
public class newContact : PageBase
{
protected System.Web.UI.WebControls.TextBox TextBox1;
protected System.Web.UI.WebControls.Button Button1;
protected System.Web.UI.WebControls.TextBox TextBox2;
private void Page_Load(object sender, System.EventArgs e)
{
}
#region Web Form Designer generated code
override protected void OnInit(EventArgs e)
{
//
// CODEGEN:该调用是 ASP.NET Web 窗体设计器所必需的。
上一页 [1] [2] [3] 下一页 [C语言系列]NET 中C#的switch语句的语法 [系统软件]托拽Explore中的文件到VB.net的窗口 [系统软件]Boost库在XP+Visual C++.net中的安装 [常用软件]新配色面板:Paint.Net3.0RC1官方下载 [常用软件]用内建的“Net Meeting”聊天 [VB.NET程序]Henry的VB.NET之旅(三)—共享成员 [VB.NET程序]Henry的VB.NET之旅(二)—构造与析构 [VB.NET程序]Henry的VB.NET之旅(一)—失踪的窗体 [VB.NET程序]在托盘上显示Balloon Tooltip(VB.NET) [VB.NET程序]Henry手记-VB.NET中动态加载Treeview节点(二)
|