我已经使用Visual Studio开发了Outlook加载项。我的插件有一个按钮,可在会议邀请的正文中填充详细信息并添加所需的与会者。这种方法在99%的时间内都有效,但是,每隔一段时间它就会给我以下javascript错误
Uncaught TypeError: Cannot read property 'BeginRequestEventArgs' of undefined
at Sys$WebForms$PageRequestManager$_onFormSubmit [as _onFormSubmit] (ScriptResource.axd?d=JnUc-DEDOM5KzzVKtsL1tUaDDFC8JI9PZoqCKFnH3HicYJzF_zpPGkOLk3MZ9rbDUE7kJXe6N0EStxh-pZYjsmQB8W2PsOL013Tr1dGNQPC0VdPkqFH0voGFXTH874eSP_RQUWM2j6iSy1EI6sm65aEvqVqWTmyeEZKMj2iHf1NGjUox3UVeubis_GTgrae00&t=fffffffffc18b87d:1282)
at Sys$WebForms$PageRequestManager$_doPostBack [as _doPostBack] (ScriptResource.axd?d=JnUc-DEDOM5KzzVKtsL1tUaDDFC8JI9PZoqCKFnH3HicYJzF_zpPGkOLk3MZ9rbDUE7kJXe6N0EStxh-pZYjsmQB8W2PsOL013Tr1dGNQPC0VdPkqFH0voGFXTH874eSP_RQUWM2j6iSy1EI6sm65aEvqVqWTmyeEZKMj2iHf1NGjUox3UVeubis_GTgrae00&t=fffffffffc18b87d:824)
at ScriptResource.axd?d=D9drwtSJ4hBA6O8UhT6CQrNUKWxdViUoX8nG6vtRorI5mgDhrJMOL_y-_3nu25XQo9Gz8CjukWnOd-x0OfIAh9FgyJeS0RrMxvSrdThT9kXeynzr3pqU_L6tTxneiig4cPTPsrpwJlxcM0ArKugqg8iT5fKHJw9ZuzRwt5pHO_M1&t=fffffffffc18b87d:47
at HTMLInputElement.onclick (AddDetails.aspx?et=:89)
如果我然后调试后面的代码并在按钮click事件上设置一个断点,则该断点甚至都不会被击中。
如果我刷新插件的任务窗格,则它将再次开始工作20次或30次单击,这是完全随机的间隔。我的页面上确实有脚本管理器和更新面板,似乎认为这是造成此问题的原因。
这是我的页面:
<body>
<form id="form1" runat="server">
<asp:ScriptManager runat="server" ID="sm" EnablePageMethods="True"></asp:ScriptManager>
<div class="ms-Fabric content-main">
<asp:UpdatePanel ID="updatepanel" runat="server" UpdateMode="Conditional">
<ContentTemplate>
<asp:HiddenField ID="Hid1" runat="server" ClientIDMode="Static" Value="Add VC Details" />
<asp:HiddenField ID="HidCallID" runat="server" ClientIDMode="Static" />
<asp:HiddenField ID="HidToken" runat="server" ClientIDMode="Static" />
<asp:HiddenField ID="HidPasscode" runat="server" ClientIDMode="Static" />
<asp:HiddenField ID="HidStart" runat="server" ClientIDMode="Static" />
<asp:HiddenField ID="HidEnd" runat="server" ClientIDMode="Static" />
<asp:HiddenField ID="HidPrevCallID" runat="server" ClientIDMode="Static" />
<asp:HiddenField ID="HidPrevToken" runat="server" ClientIDMode="Static" />
<div id="wrapper">
<asp:Label ID="Label1" runat="server" Text=""></asp:Label>
<asp:Button ID="btn_add" runat="server" Text="Add VC Details" UseSubmitBehavior="False" />
<asp:Button ID="btn_trigger" runat="server" Text="" Style="display: none" UseSubmitBehavior="False" />
<asp:Button ID="btn_update" runat="server" Text="" Style="display: none" UseSubmitBehavior="False" />
</div>
<div id="footer">
<asp:Label ID="lab_user" runat="server" Text=""></asp:Label>
<asp:Button ID="btn_logout" runat="server" Text="Sign Out" />
</div>
</ContentTemplate>
</asp:UpdatePanel>
</div>
</form>
这是添加按钮后面的代码:
Private Sub btn_add_Click(sender As Object, e As EventArgs) Handles btn_add.Click
If Hid1.Value = "Add VC Details" Then
Dim callID As Integer = getvmr()
Dim pn As New Random
Dim Passcode As Integer = pn.Next(1000, 9999)
Dim tk As New Random
Dim token As Integer = tk.Next(10000, 99999)
Dim script As String = "prependItemBody(" & callID & ", " & Passcode & ", " & token & ")"
Dim scriptKey As String = "UniqueKeyForThisScript" & Passcode
System.Web.UI.ScriptManager.RegisterClientScriptBlock(Page, GetType(Page), scriptKey, script, True)
btn_add.Text = "Update Details"
Hid1.Value = "Update Details"
ElseIf Hid1.Value = "Update Details" Then
Dim callID As Integer = getvmr()
Dim pn As New Random
Dim Passcode As Integer = pn.Next(1000, 9999)
Dim tk As New Random
Dim token As Integer = tk.Next(10000, 99999)
Dim script As String = "updateItemBody(" & callID & ", " & Passcode & ", " & token & ")"
Dim scriptKey As String = "UniqueKeyForThisScript"
ScriptManager.RegisterStartupScript(Me.Page, Me.GetType(), scriptKey, script, True)
Hid1.Value = "Update Details"
btn_add.Text = "Update Details"
End If
End Sub