1

我有一个已设置的 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 值,但我没有这些。

4

0 回答 0