There are
two types of server-side control triggering events:
1. The server-side control Button is rendered as the client's
<input type= "Submit" Name= "Button1" value= "button" id= "Button1"/>
Type type= "Submit" Such controls will be submitted via the form form after clicking, and will be sent as parameters to the server after clicking, the parameter is the control's Name property = control's value, The server side will know that this button is clicked, based on the value of the Name property of the received control, to trigger the Click event on the service side.
When we add the name attribute to the server-side control button tag, the server removes it from the front-end rendering, which also proves that the background is using the name value to get the clicked button names.
2. Background event triggering for other server-side controls
The server automatically causes the event touch of the server-side control to occur as a script:
1<script type= "Text/javascript" >2 //<! [Cdata[3 varTheform = document.forms[' Form1 '];4 if(!theform) {5Theform =Document.form1;6 }7 function__doPostBack (Eventtarget, eventargument) {8 if(!theform.onsubmit | | (Theform.onsubmit ()! =false)) {9Theform.__eventtarget.value =Eventtarget;TenTheform.__eventargument.value =eventargument; One theform.submit (); A } - } - //]]> the</script>
Then add the JS code to each control's corresponding event:
<a id= "LinkButton1" href= "Javascript:__dopostback (& #39; linkbutton1& #39;,& #39;& #39;) ">Click</a>
To invoke Dopostback to send the corresponding trigger information to the background, there are two parameters, the first is the name of the control that triggered the event, and the second is the event argument.
3. The server automatically generates hidden domain VIEWSTATE, saves the value of the server control, and saves the state when the page is postback
<input type= "hidden" name= "__viewstate" id= "__viewstate" value= "dfh5nmwjx1dnsxzn46y8jnrw6phzm5uvakten6wj9+ 0qh5o2vtlskki844uxjfmnj5w9xjbw+cvedxrkw6pmubnhup85wycvei9n8ihtvz8= "/>
Asp. NET Server-side control principle analysis