读书人

为什么有些网页的AutoEventWireup指令

发布时间: 2012-03-12 12:45:33 作者: rapoo

为什么有些网页的AutoEventWireup指令是true,有些是false啊
为什么有些网页的AutoEventWireup指令是true,有些是false啊

[解决办法]
引自:MSDN

C# code
当 AutoEventWireup 为 true 时,ASP.NET 不要求您将事件处理程序显式绑定到页事件,如 Load 。 当 AutoEventWireup 为 false 时,必须将事件显式绑定到方法。 例如,如果具有该页代码中的 Page_Load 方法,只有像如下例子所示的那样编写代码,才会在响应 Load 的事件时调用此方法。//也就说为false的时候 你要显示的绑定事件 代码如下public partial class AutoEventWireupExample : System.Web.UI.Page{     protected void Page_Load(object sender, System.EventArgs e)    {        Response.Write("Executing Page_Load");    }    override protected void OnInit(EventArgs e)    {        this.Load += new System.EventHandler(this.Page_Load);    }} 

读书人网 >asp.net

热点推荐