Invalid callback or callback argument. Receive only in case of image button

I get the following error:

Invalid callback or callback argument. Event checking is enabled using <pages enableEventValidation="true"/> in the configuration or <%@ Page EnableEventValidation="true" %> on the page. For security reasons, this function checks that the arguments for the postback or callback events are taken from the server control that originally rendered them. If the data is valid and expected, use the ClientScriptManager.RegisterForEventValidation method to register the postback or callback data for validation.

I have an ImageButton in 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 I click on this ImageButton , it causes this error.

But when I tried LinkButton instead of ImageButton , it worked 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 get this error only with ImageButton .

+4
source share
2 answers

In your IsPostBack page load check

 protected void Page_Load(object sender, EventArgs e) { if (!Page.IsPostBack) { //your code here } } 
+4
source

Usage: if(!Page.IsPostBack) (C #).

Also look at this answer , and others - at the same question

+3
source

All Articles