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

问题描述 投票:0回答:1

在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
    }
}
asp.net sharepoint updatepanel
1个回答
0
投票

执行条件更新:

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();
    }
}
最新问题
© www.soinside.com 2019 - 2024. All rights reserved.