Invalid postback or callback argument exception

rated by 0 users
This post has 11 Replies | 7 Followers

Not Ranked
Posts 21
Points 140
Teo Lachev Posted: Sun, Nov 6 2005 10:00 AM
Clicking Enter on the Sign In dialog (instead of clicking on the Sign In button) results in the following exception in ASP.NET 2.0 Invalid postback or callback argument. Event validation is enabled using in configuration or 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.
  • | Post Points: 50
Not Ranked
Posts 12
Points 210
mandelbug replied on Wed, Nov 23 2005 4:24 AM
You may need to add this attribute to <pages> tag in web.config file: enableEventValidation="false"
  • | Post Points: 35
Top 500 Contributor
Posts 68
Points 400
blindahl replied on Tue, Nov 29 2005 10:32 AM
mandelbug wrote:
You may need to add this attribute to <pages> tag in web.config file: enableEventValidation="false"
I've had the same problem - but setting the above value didn't change anything.
  • | Post Points: 20
Not Ranked
Posts 1
Points 20
Eric1776 replied on Tue, Nov 29 2005 10:24 PM
blindahl wrote:
mandelbug wrote:
You may need to add this attribute to <pages> tag in web.config file: enableEventValidation="false"
I've had the same problem - but setting the above value didn't change anything.


I had the same problem and this worked for me.
  • | Post Points: 20
Top 500 Contributor
Posts 68
Points 400
blindahl replied on Wed, Nov 30 2005 9:09 AM
arrghh.... too many sites, not enough brain cells. modified the wrong web.config. Smile [:)] works fine now.
  • | Post Points: 5
Not Ranked
Posts 4
Points 95
tweek replied on Thu, Jan 19 2006 2:18 PM
Ok dump question: isn't this a security risk? or dose CS handle this stuff?
  • | Post Points: 20
Not Ranked
Posts 1
Points 5

Yes I believe it's a bad work around.

One thing that I found was that if you are databinding in the load event you will get this error if you don't first check for postback.  I was having this problem after I added some client script to add a confirmation popup.  Just wrap your databinding in an if(IsPostback) block.

 

Joe

  • | Post Points: 5
Not Ranked
Posts 1
Points 20

My receiving this error was related to the use of the AJAX ScriptManager when I made a call to ScriptManager1.Page.ClientScript.RegisterClientScriptBlock().  I had to remove the call to RegisterClientScriptBlock on my master page to get around the 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. 

 

  • Filed under:
  • | Post Points: 20
Not Ranked
Posts 1
Points 35
Teemela replied on Thu, Jul 12 2007 5:12 AM
This happens when data is bound in the page load event, and its not in a (!IsPostback) clause.
  • | Post Points: 35
Not Ranked
Posts 1
Points 5
mrnathan replied on Thu, Aug 9 2007 12:05 PM

Hi, we were having these errors extensively on our ASP.NET 2.0 Ajax enabled site. It appeared to be happening on slower connection speeds were users were attempting login before the entire page downloaded. I built a user control, added this to our global master page, and the errors were fixed. Here is the code:

public partial class UserControls_FullLoadRequiredForPostBack : System.Web.UI.UserControl

{

          protected void Page_Load(object sender, EventArgs e)

          {

                    Page.ClientScript.RegisterHiddenField(
"PageLoadedHiddenTxtBox", "");

                   string scriptCommand = "document.getElementById('PageLoadedHiddenTxtBox').value ='Set';";

            string preSubmitCommad = "var loaded=document.getElementById('PageLoadedHiddenTxtBox').value; if(loaded=='Set'){return true};alert('please wait for page to completely load before submitting to site.');return false;";

                       Page.ClientScript.RegisterStartupScript(this.GetType(),"onLoad", scriptCommand, true);

                      Page.ClientScript.RegisterOnSubmitStatement(this.GetType(),"OnSubmit", preSubmitCommad);

           }

}

 

The RegisterStartUpScript method places the code at the end of the document, thus if this script does not run it cannot set the hidden field. The Submit checker will not allow the user to "Submit" until this field is set.

This has worked for us, we were getting many of these errors and now none.

 

Hope this helps those with these issues  

 

  • | Post Points: 5
Not Ranked
Posts 1
Points 5
bertvan replied on Mon, Dec 24 2007 8:53 AM

Where should we be databinding then? 

  • | Post Points: 5
Not Ranked
Posts 1
Points 5
kpayson replied on Wed, Feb 20 2008 5:26 PM

One cause of this error that caused me to rip my hair out until I found a solution, was that I had initiation code in the Page_Load event that was not inside of an if (! IsPostBack Wink condition.  Therefore the initiation reran.  This (I believe) caused the view state to be modified in a way that made .NET unhappy and throw the error.  Once I put the initializtion code inside of an if (! IsPostBack Wink condition,  the problem was fixed.

Note too that setting EnableEventValidation=false doesn't work.  When I tried this, the event simply didn't fire.

  • | Post Points: 5
Page 1 of 1 (12 items) | RSS
Powered by Community Server (Commercial Edition), by Telligent Systems

Copyright© 2008 Telligent Systems Inc. All rights reserved
CommunityServer.com  •  Telligent.com