Problem:
Questions about resetting
There is a type = "reset" button in HTML, which is used to indicate the status or value of the page element.
However, in the following cases, its function seems to be ineffective.
Scenario technology: Ajax & jquery & type = "reset"
Page:
<Asp: textbox id = "txtbox" runat = "server"> </ASP: textbox>
<Input id = "reset" type = "reset" class = "signedbtn"/>
Script:
<SCRIPT type = "text/JavaScript" Language = "JavaScript">
$ ("# RESET"). Click (function (){
// Reset textbox
VaR entryarr = [txtbox, txtbox1, txtbox2];
$. Each (entryarr, function (){
This. Val ("");
});
});
</SCRIPT>
AboveCodeIs the code written by the textbox.
When we add Ajax: updatepanel to the page
Page
<Ajax: updatepanel id = "up" runat = "server" updatemode = "Conditional">
<Contenttemplate>
<Asp: textbox id = "txtbox" runat = "server"> </ASP: textbox>
<Input id = "reset" type = "reset" class = "signedbtn"/>
</Contenttemplate>
</Ajax: updatepanel>
Script:
<SCRIPT type = "text/JavaScript" Language = "JavaScript">
$ ("# RESET"). Click (function (){
// Reset textbox
VaR entryarr = [txtbox, txtbox1, txtbox2];
$. Each (entryarr, function (){
This. Val ("");
});
});
</SCRIPT>
The above blue code block is basically valid only for the first execution. However, when updatepanel occurs PostBack or something, clicking the reset button again is invalid.
For the main reasons, refer:
Http://www.cnblogs.com/blodfox777/archive/2008/12/08/1347805.html
Solution:
<SCRIPT type = "text/JavaScript" Language = "JavaScript">
Function pageload (sender, argS ){
$ ("# RESET"). Click (function (){
// Reset textbox
VaR entryarr = [txtbox, txtbox1, txtbox2];
$. Each (entryarr, function (){
This. Val ("");
});
});
}
</SCRIPT>
But for the above cases,The page reset function is still invalid.
See the following
Figure 1: Click Reset
Figure 2: click "OK"
Why? Why?
Why is the value in textbox written back to textbox?
Cause: I may have analyzed the problem of type = "reset" and updatepanel. Why is it unclear?
Solution: use regular buttons
Page
<Ajax: updatepanel id = "up" runat = "server" updatemode = "Conditional">
<Contenttemplate>
<Asp: textbox id = "txtbox" runat = "server"> </ASP: textbox>
<Asp: button id = "btncancel" runat = "server" text = "reset" cssclass = "signedbtn"/>
<% -- <Input id = "reset" type = "reset" class = "signedbtn"/> -- %>
</Contenttemplate>
</Ajax: updatepanel>
Script:
<SCRIPT type = "text/JavaScript" Language = "JavaScript">
Function pageload (sender, argS ){
$ ("# <% = Btncancel. clientid %>"). Click (function (){
// Reset textbox
VaR entryarr = [txtbox, txtbox1, txtbox2];
$. Each (entryarr, function (){
This. Val ("");
});
});
}
</SCRIPT>
reference: http://forums.asp.net/p/1448643/3300979.aspx