【问题标题】:Ajax form submitting reloading pageAjax表单提交重载页面
【发布时间】:2009-04-14 20:24:05
【问题描述】:

你有调用我的aspx的js脚本

JS

new Ajax.Updater('display', '/myForm.aspx?lat=' + lat + '&lng=' + lng + '&zoom=' + zoom, { method: 'get' });

myForm.aspx 正确加载表单。但是,当我提交表单时,它会加载一个新页面。如何停止页面重新加载??

myForm.aspx

<form id="form1" runat="server" >
    <asp:ScriptManager ID="ScriptManager1" runat="server"  EnablePageMethods="true" >
</asp:ScriptManager>    
    <uc1:FlagForm ID="FlagForm1" runat="server" />    
    </form>

FlagForm.ascx

<asp:UpdatePanel ID="UpdatePanel1" runat="server">
<ContentTemplate>
<table>
<tr>
<td>Name:</td>
<td><asp:TextBox ID="TextBoxName" runat="server"></asp:TextBox></td>
</tr>
<tr>
<td>Email:</td>
<td><asp:TextBox ID="TextBoxEmail" runat="server"></asp:TextBox></td>
</tr>
<tr>
<td>Comments:</td>
<td><asp:TextBox ID="TextBoxComment" runat="server"></asp:TextBox></td>
</tr>
<tr>
<td>Marketing Opt in:</td>
<td><asp:CheckBox ID="CheckBoxOptIn" runat="server" /></td>
</tr>
<tr>
<td>Data Protection:</td>
<td><asp:CheckBox ID="CheckBoxDataProtection" runat="server" /></td>
</tr>
</table>
<asp:HiddenField ID="HiddenFieldLng" runat="server" />
<asp:HiddenField ID="HiddenFieldLat" runat="server" />
<asp:HiddenField ID="HiddenFieldZoom" runat="server" />
<asp:Button ID="ButtonSend" runat="server" Text="Send" onclick="ButtonSend_Click" />
 <asp:Label ID="LabelResults" runat="server" Text="Label"></asp:Label>
</ContentTemplate>

</asp:UpdatePanel>

【问题讨论】:

    标签: asp.net-ajax


    【解决方案1】:

    你需要取消事件——我认为在prototype.js中它是Event.stop(),但你必须看看把它放在哪里

    【讨论】:

    • hmm,你是指原始JS中的事件(即我的第一个代码块)还是通过asp.net取消事件,谢谢
    猜你喜欢
    • 2018-04-10
    • 1970-01-01
    • 2012-08-06
    • 1970-01-01
    • 2013-11-19
    • 2017-02-03
    • 2014-12-21
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多