Asp.Net: Invalid Postback or Callback Argument

Invalid postback or callback argument. Event validation is enabled using ' pages enableEventValidation=true/ '

The problem is that ASP.NET does not get to know about this extra or removed listitem.
You got an number of options (listed below):

  • Disable eventvalidation (bad idea, because you lose a little of security that come with very little cost).
  • Use ASP.NET Ajax UpdatePanel. (Put the listbox in the Updatepanel and trigger a update, if you add or remove listbox. This way viewstate and related fields get updates and eventvalidation will pass.)
  • Forget client-side and use the classic postback and add or remove the listitems server-side.

I hope this helps.

asp.net: Invalid postback or callback argument

in you aspx file you should put the first line as this :

<%@ Page EnableEventValidation="false" %>

if you already have something like <%@ Page so just add the rest => EnableEventValidation="false" %>

I recommend not to do it.

Error: Invalid postback or callback argument

1) Invalid Postback or Callback argument in GridView Problem may be: You are binding data in Page_Load event with either Object Data Source or Manual Binding with function call. This will make your GridView bind data on every event fire of any control.

When you are firing any GridView command with OnRowCommand, before RowCommand fire your GridView will rebind and all control within it will be assigned to new id. So RowCommand could not get the item which have fired the event.

Solution for Invalid Postback or Callback argument in GridView: You can bind your data within this if condition

if (!IsPostBack)
{
//Your code for Bind data
}

This code will definitely give you solution if this not work then check whether any other control is not giving error.

Invalid postback or callback argument.Event validation is enabled using

I had the same problem.
In my case the problem was caused because I was inserting javascript inside the form tag and that javascript was submitting the form. The code worked well for years until I moved my solution from .NET 3.5 to 4.5.1 .
In an ASP.NET WebForm there are some hidden fields generated automatically. One of these fields is the __EVENTVALIDATION field, which acts as a safeguard against posting unauthorised data (like adding an extra option into a DropDownList server control from javascript).

<input type="hidden" name="__EVENTVALIDATION" id="__EVENTVALIDATION" value="/wEdAAN+KgYAJkWoXhOSD3+DUVvd3588JQsnNAC5MN7/uyI1ci6YmP63wnPMGlpCSu3QTgdg0MzSFI9etYOG29clJ48nEH4YX8U9SWslVBX+CGpmog==" />

Usually these hidden fields are generated as the first elements inside the form. However after upgrading this element started to appear as the last element inside the form, just underneath my javascript that was doing the submitting. Therefore this field was not sent as part of the request and the server was interpretting this as an attempt to post unauthorised data.

After a bit of research I found that there is a configuration inside the web.config that you can use to control the placement of the fields:

<system.web>
<pages renderAllHiddenFieldsAtTopOfForm="true" />
</system.web>

However this is by default true so it had no effect. And after researching this configuration and finding a partial answer here Why is the renderAllHiddenFieldsAtTopOfForm configuration setting ignored?
, I used Resharper + DotPeek + the code from http://http://referencesource.microsoft.com/ to debug inside System.Web assembly. I found that in debug mode the InnerWriter property was not HttpWriter, but type of Microsoft.VisualStudio.Web.PageInspector.Runtime.Tracing.BrowserLinkExecutionListener.PassthroughPositionTracker.PassthroughTextWriter. The PageInspector feature was interfering with the page rendering.

MY SOLUTION:

Disabling PageInspector (I did not need it at all), by inserting the following tag in the appsettings section inside the web.config :

<appSettings>
<add key="PageInspector:ServerCodeMappingSupport" value="Disabled" />
</appSettings>

And this worked for me. More info here http://bchavez.bitarmory.com/archive/2012/12/28/rip-page-inspector-out-of-your-web-site-projects-now.aspx

Invalid postback or callback argument. Why?

This has to be one of the most frustrating error messages in .NET, but once you get a feel for what's going on, it makes sense. .NET likes to know EVERYTHING that's going on. It keeps track of all the elements that it has placed on the page. Along those same lines, .NET gets offended when it receives input from something it didn't know about. In your case, it sounds like, at the time you click on the LinkButton, .NET doesn't think it should be there. In my experience, there are two likely reasons for this:

  1. You're doing to client-side wizardry that is creating new inputs or cloning existing inputs.

  2. While the form submission is being processed, .NET does something to the LinkButton which causes it to be no longer available. Some examples of this I've run into are when your LinkButton is dynamically created in the backend or you're using UpdatePanels and their content get changed during the form's submission.

Basically, I believe if you step through the form submission code and watch that LinkButton, you'll see .NET forget about it, which understandably triggers this "Security Exception" when the LinkButton is clicked.

Invalid postback or callback argument error?

If you want to modify generated controls from client side, you have to disable eventvalidation or register all possible values with RegisterForEventValidation.
It's well explained here.
It's because the data sent to the client and received after by the server differs.

edit:also responded here.

Invalid postback or callback argument

Try to do like this in your Page_Load

if (!Page.IsPostBack)
{
//do something
}

may this will help you.



Related Topics



Leave a reply



Submit