如PageBase定义了一个Alert过程
Alert(string s)
{
    response.write("<script>alert('"+s+"');</script>");
}然后在页面
index.aspx.cs中
先把system.web.ui.page换成PageBase
然后在
Page_load()
{
   Alert("网页载入");
}
这样在网页加载的时候会有这个弹出窗口
现在我想要的是

Page_load()
{
}
这里不写代码也要有上面的功能
也就是返load的代码写在PageBase中
要怎么办??
谢谢PS:以上代码只是我现在手写没有测试,也可能写法或规格错误,但大概意思是这样的

解决方案 »

  1.   

    namespace TopWin.Common
    {
    /// <summary>
    /// ASPX页面的基类
    /// </summary>
    public class PageBase : System.Web.UI.Page
    {
     
    #region Web 窗体设计器生成的代码
    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 private void Page_Load(object sender, System.EventArgs e)
    {
      response.write("<script>alert('"+s+"');</script>"); }
    }
    }
      

  2.   

    谢谢winner2050 
    我页遇到了这个问题