Saturday, November 28, 2009

How events work in ASP.net

  1. When an input control is associated with a server event, ASP.net renders it to the client browser with a JavaScript function attached.
  2. Additionally, there are few hidden variables rendered in the page to store the control name and arguments related to an event.
  3. The generic function, attached to the control, exists as __doPostBack with eventTarget and eventArguments that can accommodate the input control’s name and any associated arguments. This function, __doPostBack, fills the hidden variables and does a form submit to the server.
  4. The server when receives the form data, it decodes from hidden variables to identify the control that invoked the server postback and calls the appropriate server event method.

A much more detailed information is available here:
http://sanalksankar.blogspot.com/2009/12/event-asp-net-form-submit-postback-page.html