Wednesday, January 30, 2008

Invalid postback or callback argument

Invalid postback or callback argument. Mostly this error comes with asp.net and ajax both use because eventvalidation feature compare server postback data with client post back. The error is:


Invalid postback or callback argument. Event validation is enabled using 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.


Set EnableEventValidation="true" is not a good solution for this problem. First it must to be find which control value is not validate. For this I find this link is very useful:


http://couldbedone.blogspot.com/2007/09/conditional-updatepanel-and-event.html


after finding controls name register it with override Render function.


protected override void Render(HtmlTextWriter writer)
{
Page.ClientScript.RegisterForEventValidation(ddlShipping.UniqueID); Page.ClientScript.RegisterForEventValidation(ddlCountry.UniqueID);
base.Render(writer);
}


Use override method after page load.
Some more link for help this :


http://odetocode.com/Blogs/scott/archive/2006/03/20/3145.aspx
http://odetocode.com/Blogs/scott/archive/2006/03/21/3153.aspx


I hope it help.Thanks


Suggestions are always welcome.


Thanks.