I am getting the following error :
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.
I have an ImageButton
in a Repeater
like this:
<asp:ImageButton ID="btn_CreatePdf" ImageUrl="~/images/download.png"
ToolTip="Create Transmittal for this Contact"
CommandName="CreatePdf"
CommandArgument='<%#Eval("contactid")%>' runat="server" />
When ever I click on this ImageButton
, it causes that error.
But when I tried LinkButton
instead of ImageButton
, it's working fine. I tried following LinkButton
:
<asp:LinkButton ID="btn_CreatePdf" Text="Download" CommandName="CreatePdf"
CommandArgument='<%#Eval("contactid")%>' runat="server" >
</asp:LinkButton>
Please give me a solution, why I'm getting this error only in case of ImageButton
.
In your page load check of IsPostBack
protected void Page_Load(object sender, EventArgs e)
{
if (!Page.IsPostBack)
{
//your code here
}
}