Hi whether the submit button click event information is stored in _viewstate property(in page source) or not. if yes, how the server identifies the button is clicked from the viewstate and perform the corresponding event handler.
1 Answers
For button click event, it happens in two ways.
a. If javascript is available & UseSubmitBehavior is set to false, then it populates __EventTarget hidden field with the Unique id of the button. When the page is processing the postback, it looks for this __EventTarget in the Request.Forms and if available, does a FindControl for the corresponding value and type casts into IPostBackEventHandler and invokes RaisePostBackEvent method. The button class will then trigger the Click event.
b. If Javascript is not available & UseSubmitBehavior is set to true, then the browser sends the unique id of the button to the server as Form variables. The Page if it finds the UniqueId as the key in Request.Forms then it would again find the control using FindControl method and casts into IPostBackEventHandler and invokes RaisePostBackEvent method. The button class will then trigger the Click event.

- 13,043
- 3
- 52
- 88
-
Hi, thank you for your reply it is correctly matched, what is the unique id, whether the uniqueid is created only for the clicked button control or all other controls in the page also.. please reply me as soon as possible – Karthick Apr 10 '12 at 09:01
-
Unique ID is created for all the server side controls while rendering the page. It is an ID which can be used for finding a control at server side. This is unique for each control. – Ramesh Apr 10 '12 at 09:13
-
hi thanks this is my interview question, if i have the one textbox with two submit buttons with id button1, button2 then i click the button1 how does the server knows button1 is clicked, does the uniqueid for button1 only send to the server, what about button2, please help me,, if any tutorial available please send me the link along with your response. – Karthick Apr 10 '12 at 11:04
-