WebApplication Performance and Asp.net Page Property AutoEventWireUp


Get or set value indicating whether events for ASP.NET pages are automatically bind to event handling functions

WebApplication Performance and Asp.net Page Property AutoEventWireUp


Get or set value indicating whether events for ASP.NET pages are automatically bind to event handling functions.


Property value

Type:Boolean

true if events for ASP.NET pages automatically bind to event handling functions otherwise false.The default is true.


When AutoEventWireup is true,ASP.NET does not require you to expicitly attach your event handlers to page events such as Load.


for example,if you have Page_Load method in your code for a page with valid signature.So when AutoEventWireUp is true then handlers are automatically bound to events at run time based on their name and signatureFor each event,ASP.NET searches for a method that is named according to the pattern Page_eventname.ASP.NET checks first for an overload that has the typical event-handler signature (Sender object EventArgs e).When AutoEventWireUp is false, you explicitly bind event handling fuction to events. in that case method name do not have to follow a pattern.


Tips:



  • Do not set AutoEventWireUp to true if performance is key consideration.When it is true,ASP.NET must make 15 and 30 tries to match events with methods.

  • When AutoEventWireUp is true make sure that you do not explicitly bind event to event handling functions becuase in that case handlers might be called more than one time.
  • You can also overrides event handling methods of the page instead of binding events.

    • For example,



      protected override void OnLoad(EventArgs e)
      {
      base.OnLoad(e);
      }


Comments

No responses found. Be the first to comment...


  • Do not include your name, "with regards" etc in the comment. Write detailed comment, relevant to the topic.
  • No HTML formatting and links to other web sites are allowed.
  • This is a strictly moderated site. Absolutely no spam allowed.
  • Name:
    Email: