This error occurs when the mapping between
the controls in the .aspx page and the corresponding events in the code-behind
file is changed.
For example if you try to fire the Button1_Click event while clicking Button2 then this error will occur.
Invalid postback or callback argument.
Event validation is enabled using <lpages
enableEventValidation="true"/> in configuration or <l%@ 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.
This is done explicitly by Asp.net to make sure that there are no breach is security, to prevent some hacking script to trigger the code-behind events.
Solution
1. If your application is not a very critical or if it a restricted intranet application then you can set the enableEventValidation attribute in the @Page directive to false, this will prevent Asp.net from checking the control-event mappings
1. If your application is not a very critical or if it a restricted intranet application then you can set the enableEventValidation attribute in the @Page directive to false, this will prevent Asp.net from checking the control-event mappings
EnableEventValidation="false"
2. If your application is critical then you
can use the ClientScriptManager.RegisterForEventValidation
method to register the postback.
No comments:
Post a Comment