public   class   MyModule   :   PageModule  
{  
      protected   override   OnPrePageExecute(   object   sender,   EventArgs   e   )  
      {  
            Page.Load   +=   new   EventHandler(   Page_Load   )  
      }  
   
      private   Page_Load(   object   sender,   EventArgs   e   )  
      {  
          //TODO:   将代码写在这里。  
      }  
}   

解决方案 »

  1.   

    这是ASP.net页面生命周期,不可能不执行的,但你可以换一种思路去解决:        private bool exit = false;
            protected override void OnInit(EventArgs e)
            {
                if(某些条件)
                   exit = true;
                base.OnInit(e);
            }
            protected void Page_Load(object sender, EventArgs e)
            {
                if(exit)
                    return;
                if (!IsPostBack)
                {
                    InitForm();
                }
            }
      

  2.   

    RE:Page.Load   +=   new   EventHandler(   Page_Load   )  
    ----------------
    这种方法是添加一个事件RE:
    private bool exit = false;
            protected override void OnInit(EventArgs e)
            {
                if(某些条件)
                   exit = true;
                base.OnInit(e);
            }
    -----------------------
    能不能不要再override OnInit外面写其他代码
    就在Init中写能不能实现这个功能啊谢谢
      

  3.   

    如果要做到的话用Response.End()就可以了。不过这应该不是你要的效果。
      

  4.   

    这有点钻牛角尖了吧,我已经说了,这是ASP.NET的生命周期,你不可能在某个事件中阻止其他的事件的进行。
      

  5.   

    这样的话可以用设置flag来做。上面已经有代码了。除了用field也可以用 Context.Items[key]来存储flag.