Reputation: 171
we have this updatepanel with this listview.
<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>
after updating the listview with searchResultLV.DataBind(); in a partial postback and click on this button in the corresponding master.page
<button id="LogoutAnchor" runat="server" onserverclick="LogoutAnchor_ServerClick" class="btn btn-default btn-flat">Sign out</button>
before the function (LogoutAnchor_ServerClick) is called, an error occured:
[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.]
is this a bug? can we not use partial postback and full postback on server?
Upvotes: 1
Views: 807
Reputation: 282
Move all the code in Page_Load
event as follows.
protected void Page_Load(object sender, EventArgs e)
{
if(!IsPostBack)
{
// all your code here which should be executed only once
}
}
<%@ Page EnableEventValidation="false" %>
Upvotes: 1