I know about the viewstate and dopostback and everything, I just don’t know where the reference to the fired event goes. Say, button1.click is fired, then when the page goes through the postback cycle, and then page.load is executed, then the raised event must be executed, but how does asp.net know which event it was?
I know about the viewstate and dopostback and everything, I just don’t know where
Share
The content posted with request that is made when you click a button for example, contains the name of the control that raised the event. In the following, I used an HTTP Headers reader tool that shows the information sent in an HTTP request and checked the requests sent by clicking two buttons on a Web Form. Each request has a different value set for Button= in the post data under content.
Update: To augment my answer, consider the following content that is posted to the server when two events are sent to the server at the same time (e.g. a Button.Click and
a ComboBox.SelectedIndexChanged).
_VIEWSTATE=view state encrypted blah blah &_EVENTVALIDATION=event validation encrypted blah blah&DropDownList1=Three&Button1=Button
So the form is built in a way that event information is added to the HTTP request that is posted to the server. The parameters contain the names of the controls that rose the event and I think all of this is encrypted in the __EVENTVALIDATION parameter that makes sure that no tampering occured in the events that were raised and the controls that raised them. Its like a hash of the event information.