Outlook add-in, Cannot read property 'BeginRequestEventArgs' of undefined

瘦欲@ 提交于 2020-03-02 18:59:46

问题


I've developed a Outlook add in using Visual Studio. My plugin has a button that populates details in the body of a meeting invite and adds a required attendee. This works 99% of the time, however , every so often it gives me the below javascript error

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)

If I then debug the code behind and set a break point on the button click event, this break point does not even get hit.

If I refresh the task pane of the plugin then it starts working again for another 20 or 30 clicks, its totally random intervals. I do have a script manager and update panel on the page and seem to think this is causing it.

Here is my page:

<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>

and here is the code behind of the add button:

    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

来源:https://stackoverflow.com/questions/52984592/outlook-add-in-cannot-read-property-beginrequesteventargs-of-undefined

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!