page load after postback - how does it know?

  • Thread starter Thread starter oaksong
  • Start date Start date
O

oaksong

Looking at the locals I have "ME" and "sender". I've just clicked on a
dropdownlist and it's fired a post back. I'm in the page_load. I know
that after the page_load is complete it will fire the click event
handler for my dropdownlist, which indicates, since I've got several
of these, that it knows which one fired.

The question is: How does it know? Is there something in "Me" or
"sender" that tells it what I clicked on? This seems to me to be a
fairly rudimentary question, yet I'm not having any luck finding an
answer via the usual search mechanisms.

tia
Chris
 
Looking at the locals I have "ME" and "sender". I've just clicked on a
dropdownlist and it's fired a post back. I'm in the page_load. I know
that after the page_load is complete it will fire the click event
handler for my dropdownlist, which indicates, since I've got several
of these, that it knows which one fired.

The question is: How does it know? Is there something in "Me" or
"sender" that tells it what I clicked on? This seems to me to be a
fairly rudimentary question, yet I'm not having any luck finding an
answer via the usual search mechanisms.

tia
Chris

When a page submits a form, .NET will implement the
IPostBackEventHandler interface. This interface defines the
RaisePostBackEvent method which is receiving the data from the control
and will get fired when a postback is triggered. This method depends
on the type of the control and will look up for an associated event
handler to run it.

See more in The ASP.NET Page Object Model article:
http://msdn2.microsoft.com/en-us/library/aa479007.aspx
 
its pretty simple. a control implements the IPostBackEventHandler interface.
that control then renders some javascript that will do the postback. the
javascript call includes the control name and arguments. this are stored in a
hidden field, then a submit is done.

on the server side, on a postback, if the postback event hidden field
contains a value, it looks up the control with that id, and calls the
IPostBackEventHandler method. the control then decides how to fire the event
itself, and what to pass.

-- bruce (sqlwork.com)
 
Back
Top