Sys.WebForms.PageRequestManagerServerErrorException:无效的回发或回调参数

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了Sys.WebForms.PageRequestManagerServerErrorException:无效的回发或回调参数相关的知识,希望对你有一定的参考价值。

在SharePoint上,无法通过由外部Web控件生成的事件多次显示/隐藏更新面板内的表行,即更新面板不止一次,即,它仅在第一个ddl项目选择上起作用(尽管它功能完全在SharePoint上下文之外)。

抛出的错误:

SCRIPT5022: Sys.WebForms.PageRequestManagerServerErrorException: Invalid postback or callback argument.  Event validation is enabled using <pages enableEventValidation="true"/> in configuration or <%@ Page EnableEventValidation="true" %> in a page.  For security purposes, this feature verifies that arguments to postback or callback events originate from the server control that originally rendered them.  If the data is valid and expected, use the ClientScriptManager.RegisterForEventValidation method in order to register the postback or callback data for validation.

aspx文件:

<asp:TableRow runat="server" ID="tbr1">
    <asp:TableCell ID="tbc" runat="server" CssClass="ms-formbody">
        <asp:DropDownList ID="ddl" runat="server" EnableViewState="true" AutoPostBack="true" OnSelectedIndexChanged="ddl_SelectedIndexChanged" />
    </asp:TableCell>
</asp:TableRow>
<asp:TableRow ID="tbr2">
    <asp:TableCell>
        <asp:UpdatePanel ID="udp" runat="server" UpdateMode="Always">
            <ContentTemplate>
                <asp:Table ID="tb" runat="server">
                    <asp:TableRow runat="server" ID="tbr21">
                    <%-- content --%>
                    </asp:TableRow>
                </asp:Table>
            </ContentTemplate>
            <Triggers>
                <asp:AsyncPostBackTrigger ControlID="ddl" EventName="SelectedIndexChanged" />
            </Triggers>
        </asp:UpdatePanel>
    </asp:TableCell>
</asp:TableRow>

aspx.cs文件:

protected void ddl_SelectedIndexChanged(object sender, EventArgs e){
    if (ddl.SelectedItem.Text == "value1"){
        tb.Visible = true;
        // instruction here
    } else {
        tbdadospessoais.Visible = false;
        // instruction here
    }
}
答案

执行条件更新:

aspx文件:

<asp:TableRow runat="server" ID="tbr1">
    <asp:TableCell ID="tbc" runat="server" CssClass="ms-formbody">
        <asp:DropDownList ID="ddl" runat="server" EnableViewState="true" AutoPostBack="true" OnSelectedIndexChanged="ddl_SelectedIndexChanged" />
    </asp:TableCell>
</asp:TableRow>
<asp:TableRow ID="tbr2">
    <asp:TableCell>
        <asp:UpdatePanel ID="udp" runat="server" UpdateMode="Always">
            <ContentTemplate>
                <asp:Table ID="tb" runat="server">
                    <asp:TableRow runat="server" ID="tbr21">
                    <%-- content --%>
                    </asp:TableRow>
                </asp:Table>
            </ContentTemplate>
        </asp:UpdatePanel>
    </asp:TableCell>
</asp:TableRow>

aspx.cs文件:

protected void ddl_SelectedIndexChanged(object sender, EventArgs e){
    if (ddl.SelectedItem.Text == "value1"){
        tb.Visible = true;
        // instruction here
        upd.update();
    } else {
        tbdadospessoais.Visible = false;
        // instruction here
        upd.update();
    }
}

以上是关于Sys.WebForms.PageRequestManagerServerErrorException:无效的回发或回调参数的主要内容,如果未能解决你的问题,请参考以下文章