The requirement is as follows: Some rows in the gridview have not been processed. If you click this row, the user has processed this row, the row State must be the same as that of the normal one, but the gridview does not process the row event. You must use JavaScript to call the background event, if you are careful, you will find that after we add a linkbutton on the page and add an event to it, it is actually returned through JavaScript.
When we add a linkbutton, generate the page and view
Source code , You will find more than before linkbutton is added
Code
<Div>
<Input type = "hidden" name = "_ eventtarget" id = "_ eventtarget" value = ""/>
<Input type = "hidden" name = "_ eventargument" id = "_ eventargument" value = ""/>
</Div>
<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>
The linkbutton event is actually a javascript event.
<A id = "linkbutton1" href = "javascript :__ dopostback ('linkbutton1','') "> linkbutton </a>
So if this part of JavaScript above is available, can I use JavaScript to return it?
Yes, of course, but we need to note that we need to modify the enableeventvalidation attribute of the page. The default value is true. We can change it to false, <% @ page enableeventvalidation = "false" %> is used on the page. Otherwise, an error is returned.
The following is the linkbutton callback event that I use the HTML control to call.
<Input id = "button1" type = "button" value = "button" onclick = "_ dopostback ('linkbutton1','') "/>
If you need to use js to return the code that day, and there is no control on the page that can be added to generate the code, then copy the code above to the page, right ,:-)
Note that this method can call events of existing controls. You cannot call a method. You do not know if any other method can be implemented.