Create Reset Button in ASP.NET Webform Using JavaScript
Here is the code of Reset Button.
You need to add Following single line of code for the button’s OnClientClick event (you don’t require any code in a .cs page).
OnClientClick=”this.form.reset();return false;” CausesValidation=”false”
See Demo (http://aspspider.info/sobhagya/clearbutton.aspx)
Check the code:
<form id="”form1″" runat=”server”>
<div>
<table class=”style1″>
<tr>
<td class=”style3″>
Name </td>
<td class=”style4″>
<asp:TextBox ID="”txtNM”" runat=”server” Text=”">
</asp:TextBox>
</td>
</tr>
<tr>
<td class=”style3″>
Password</td>
<td class=”style4″>
<asp:TextBox ID="”txtPS”" runat=”server” TextMode=”Password”>
</asp:TextBox>
</td>
</tr>
<tr>
<td class=”style3″>
Gender</td>
<td class=”style4″>
<asp:RadioButtonList ID="”RadioButtonList1″" runat=”server” RepeatDirection=”Horizontal”>
<asp:ListItem>Male</asp:ListItem>
<asp:ListItem>Female</asp:ListItem>
</asp:RadioButtonList>
</td>
</tr>
<tr>
<td class=”style3″>
Course</td>
<td class=”style4″>
<asp:DropDownList ID="”DropDownList1″" runat=”server”>
<asp:ListItem>-Select-</asp:ListItem>
<asp:ListItem>.NET</asp:ListItem>
<asp:ListItem>JAVA</asp:ListItem>
<asp:ListItem>PHP</asp:ListItem>
</asp:DropDownList>
</td>
</tr>
<tr>
<td class=”style3″>
</td>
<td class=”style4″>
</td>
</tr>
<tr>
<td class=”style2″ colspan=”2″>
<asp:CheckBox id="”chk”" runat=”server”/> Agree with T&C ?</td>
</tr>
</table>
<br />
<asp:Button id="”btn”" runat=”server” Text=”Clear” OnClientClick=”this.form.reset();return
false;”CausesValidation=”false”/>
</div>
</form>