更新更新面板中的列表视图,并在母版页上回发



我们有这个带有这个列表视图的更新面板。

<asp:UpdatePanel ID="searchResultUpdate" runat="server">
            <Triggers><asp:AsyncPostBackTrigger ControlID="submitBT"/></Triggers>
            <ContentTemplate>
                <div id="status" runat="server" />
                <asp:ListView ID="searchResultLV" runat="server" OnItemCommand="searchResultLV_ItemCommand" DataKeyNames="Message_id" OnItemDeleting="searchResultLV_ItemDeleting">
                    <LayoutTemplate>
                        <table class="table table-hover">
                            <tr runat="server" id="itemPlaceholder" />
                        </table>
                    </LayoutTemplate>
                    <ItemTemplate>
                    </ItemTemplate>
                </asp:ListView>
            </ContentTemplate>
        </asp:UpdatePanel>

使用searchResultLV.DataBind()更新列表视图后;在部分回发中,然后在相应的主页面中单击此按钮

<button id="LogoutAnchor" runat="server" onserverclick="LogoutAnchor_ServerClick" class="btn btn-default btn-flat">Sign out</button>

在调用函数(LogoutAnchor_ServerClick)之前,出现了一个错误:

[ArgumentException: 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.]

这是个虫子吗?我们可以不在服务器上使用部分回发和完全回发吗?

  1. 按如下方式移动Page_Load事件中的所有代码。

    protected void Page_Load(object sender, EventArgs e) { if(!IsPostBack) { // all your code here which should be executed only once } }

    1. 在此处进行以下更改

    <%@ Page EnableEventValidation="false" %>

最新更新