Html按钮在Google Chrome中触发两个回发

时间:2013-02-27 10:43:32

标签: asp.net .net ajax vb.net postback

我有一个Html按钮,我设置了runat="server"。当我单击此按钮时,我有时会执行两次按钮代码,但仅限于在Chrome浏览器中运行时。我知道我可以期待这一点,因为按钮位于更新面板中,但是当我在Chrome中运行时,我无法确定异步回发,因为值始终相同(即使在第二次执行时):

IsPostBack = True
IsCallback = False
ScriptManager.GetCurrent(Me).IsInAsyncPostBack = True
ScriptManager1.IsInAsyncPostBack = True

aspx页面如下:

<form id="form1" runat="server">
<div>
    <asp:ScriptManager ID="ScriptManager1" runat="server">
    </asp:ScriptManager>

    <asp:UpdatePanel ID="UpdatePanel1" runat="server">
        <ContentTemplate>  
            <button id="btnHtml1" runat="server" class="toolStripButton"><img src="../Images/ManLate32.png" alt="[Man Late]"/><br />Html Button</button>
            <button id="btnHtml2" runat="server" class="toolStripButton"><img src="../Images/PayCategory32.png" alt="[Pay Category]"/><br />Html Button 2</button>
        </ContentTemplate>
    </asp:UpdatePanel>

</div>
</form>

我的守则背后:

Public Class ChromeBug
    Inherits System.Web.UI.Page

    Private Sub btnHtml1_Click(sender As Object, e As System.EventArgs) Handles btnHtml1.ServerClick
        Globals.SubmitCount += 1
        Debug.WriteLine(String.Format("Submit Count:{0} IsPostBack:{1} IsCallBack:{2} IsAsyncPostBack:{3} IsInAsyncPostBack2:{4}", Globals.SubmitCount, IsPostBack, IsCallback, ScriptManager.GetCurrent(Me).IsInAsyncPostBack, ScriptManager1.IsInAsyncPostBack.ToString))
    End Sub

    Private Sub btnHtml2_Click(sender As Object, e As System.EventArgs) Handles btnHtml2.ServerClick
        Globals.SubmitCount += 1
        Debug.WriteLine(String.Format("Submit Count:{0} IsPostBack:{1} IsCallBack:{2} IsAsyncPostBack:{3} IsInAsyncPostBack2:{4}", Globals.SubmitCount, IsPostBack, IsCallback, ScriptManager.GetCurrent(Me).IsInAsyncPostBack, ScriptManager1.IsInAsyncPostBack.ToString))
    End Sub
End Class

我尝试添加webkit javascript文件,但似乎没有任何效果。我在很多地方也读到这是因为空的src值,但我没有这些。

0 个答案:

没有答案