在 SharePoint 上,无法通过外部网络控件生成的事件在更新面板内显示/隐藏表格行更新面板不止一次, ie ,它仅在第一个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
}
}
答案 0 :(得分: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();
}
}