What does AutoEventWireUp page property mean?

前端 未结 3 1008
一整个雨季
一整个雨季 2020-11-29 01:57

I don\'t understand what the AutoEventWireUp page property is responsible for.

While surfing the net, I have found a lot of forums with discussions abou

3条回答
  •  庸人自扰
    2020-11-29 02:18

    As mentioned in the article, if you have AutoEventWireUp turned on, asp.net will automatically recognize you have a method with the page_load syntax and call it automatically:

    private void Page_Load(object sender, System.EventArgs e)
    {
    }
    

    This gives you a cleaner code behind at the expense of some (very) small overhead. Notice that if you don't specify it you must explicitly tell asp.net you want to handle the page load event:

    this.Load += new System.EventHandler(this.Page_Load);
    

    Note that this applies to other events in the page, as it uses a naming convention as Page_Event.

提交回复
热议问题