I'm trying simply call JavaScript to reset the form and this is added, I'm guessing, from script manager. When I click the reset butt on now, rather than resetting the form I get a postback. Any idea why script manager does this and what I can do to prevent the postback?
Hi Travich,
Here is the sample that you can reference to.
<%@. Page Language="C#" %><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><script runat="server"></script><html xmlns="http://www.w3.org/1999/xhtml" ><head runat="server"> <title>Untitled Page</title></head><body> <form id="form1" runat="server"> <asp:ScriptManager ID="ScriptManager1" runat="server"> </asp:ScriptManager><%=DateTime.Now.ToString()%> <asp:TextBox ID="TextBox1" runat="server"></asp:TextBox> <input id="Reset1" type="reset" value="reset" style="display:none" /> <asp:Button ID="Button1" runat="server" Text="ResetForm" OnClientClick="resetForm();return false;"/> <script language="javascript" type="text/javascript"> function resetForm(){ $get("Reset1").click(); } </script> </form></body></html>
I hope this help.
Best regards,
Jonathan
0 件のコメント:
コメントを投稿