Abstract:
In ASP. ent, there are two mechanisms for implementing page PostBack. No matter which callback method is used, Form submission is final.
I. Original Form submission
The buttons and imagebutton controls in webcontrols are converted
HtmlCode
<Input type = "Submit" name = ""/> <input type = "image" name = ""/>
Ii. Form submission using JavaScript and hidden forms
In addition to buttons and imagebutton, other webcontrols controls implement the page return mechanism in this way. The procedure is as follows:
1. If there are server controls except button and imagebutton on the page, the ASP. NET page framework automatically adds two hidden forms to the page.
HTML code
<Input type = "hidden" name = "_ eventtarget" id = "_ eventtarget" value = ""/> <input type = "hidden" name = "_ eventargument "id =" _ eventargument "value =" "/>
2. The server automatically generates the following JavaScript method to process event sending.
JavaScript code
<SCRIPT type = "text/JavaScript"> <! -- Var theform = Document. Forms ['form1 ']; If (! Theform) {theform = Document. form1;} function _ dopostback (eventtarget, eventargument) {If (! Theform. onsubmit | (theform. onsubmit ()! = False) {theform. _ eventtarget. value = eventtarget; theform. _ eventargument. value = eventargument; theform. submit () ;}/// --> </SCRIPT>
3. Each control that will trigger a server event will call the above Code in the response client event.
The following uses the <asp: linkbutton> server control as an example to describe the ing between the server and the client:
HTML code
<A id = "linkbutton1" href = "javascript :__ dopostback ('linkbutton1','') "> linkbutton </a>
Note: server controls such as <asp: checkbox> and <asp: textbox> do not automatically generate the _ dopostback method called by JS on the client.
4. after the client triggers an event, it calls the _ dopostback method. The eventtarget and eventargument parameters of the triggered control source are respectively paid to the two hidden domains _ eventtarget and _ eventargument, and then submits the form, on the server side, determine which control event is triggered Based on _ eventtarget and _ eventargument.