Click here to Skip to main content
14,971,296 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi I am using grid view to populate data from database, but when I click next page button of grid view I am getting 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 saw somewhere to add following line to aspx page

<%@ Page EnableEventValidation="false" %>
when I used it, it gives another exception
The directive 'Page' is unknown
Posted
Comments
saguptamca 3-Oct-13 10:11am
   
What is clientidmode of gridview
[no name] 4-Oct-13 0:52am
   
I didn't assigned any clientmode, should I assign it? What should be the value? thanks
idenizeni 3-Oct-13 12:40pm
   
The @ Page directive should go in a page (.ascx) and not a control (.ascx). Also, if you are only trying navigate pages in the gridview then I don't believe you want to set EnableEventValidation to true.
[no name] 4-Oct-13 0:55am
   
Yup, it should be false, but I am treating .ascx control as a page here. Any better idea?
idenizeni 4-Oct-13 1:54am
   
You can 'treat' the .ascx control as a page all you want but the ASP.Net framework will never agree with you. If you really want this to work you need to put the @ Page directive in the .aspx page that you are loading the .ascx control into.
[no name] 4-Oct-13 2:19am
   
Its solved sir, thank you for ur help :)
idenizeni 4-Oct-13 2:55am
   
You're welcome :)
Azee 3-Oct-13 12:42pm
   
Could you please post your code as well?

1 solution

Hi you should use <%@ Page EnableEventValidation="true" %> not false is page directive
   
Comments
[no name] 4-Oct-13 0:42am
   
when I used @page, it gives another exception
The directive 'Page' is unknown
[no name] 4-Oct-13 0:44am
   
And it is ascx not aspx, so I guess that is the reson for The directive 'Page' is unknown exception

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)




CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900