当从javascript调用时,UpdatePanel中的asp.net按钮会导致Firefox 15.0.1中的整个页面刷新

Rob*_*anc 2 .net c# asp.net

好的,这是一个奇怪的.

我正在使用.net框架4.我在updatepanel中有一个asp.net按钮,如下所示:

<asp:Button id="btNacinMontaze" runat="server" class="buttonOIHidden" value="nm" CausesValidation="false" onclick="btNacinMontaze_Clicked" clientidmode="Static" UseSubmitBehavior="false"/>
Run Code Online (Sandbox Code Playgroud)

如果我在浏览器中单击它它可以正常工作 - updatepanel更新自己而不刷新整个页面,正确的服务器事件被触发.

如果我在页面内这样做: document.getElementById("btNacinMontaze").click();

整个页面刷新并触发正确的服务器事件.

如果我从firebug控制台中发出相同的代码行,则只需刷新updatePanel.

如果我在Chrome或IE9中加载相同的页面,它在所有情况下都可以正常工作.我已经跟踪了点击鼠标和通过在Firebug中调试点击代码之间的不同,并在Sys$WebForms$PageRequestManager$_doPostBack方法中看到了该行

if (!this._postBackSettings.async)
Run Code Online (Sandbox Code Playgroud)

是不同的.单击鼠标时异步为true,代码单击为false.

我不知道为什么会发生这种情况,并且非常感谢任何帮助.

Sli*_*SFT 6

您应该定义一个AsyncPostBackTrigger停止整个页面刷新.

<asp:UpdatePanel runat="server" ID="UpdatePanel1" UpdateMode="Conditional">
   <ContentTemplate>
     <asp:Label ID="label" runat="server"></asp:Label>
   </ContentTemplate>
   <Triggers>
     <asp:AsyncPostBackTrigger ControlID="btNacinMontaze" EventName="Click" />
   </Triggers>
 </asp:UpdatePanel>
Run Code Online (Sandbox Code Playgroud)