Lions Den

The Code and Times of Hanan Schwartzberg

About Hanan | Hanan's CV | Contact Hanan

January 16, 2016

ASP.NET – Invalid postback or callback argument (An unexpected cause)

Filed under: ASP.NET,C# — Tags: , , , — Hanan Schwartzberg @ 9:20 pm

The Issue

Causing a postback (full or partial) causes 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.

With nothing added to the page on the client side, it’s not clear what data is causing the error.

The Solution

The problem in this case is being caused by a data object on the page being rebound in the page load event. To solve the issue make sure the databind only runs the first time the page loads.

if (!IsPostBack)
{
    rptStuff.DataSource = linqClass.FetchData();
    rptStuff.DataBind();
}

No Comments »

No comments yet.

RSS feed for comments on this post. TrackBack URL

Leave a comment

Anti-Spam by WP-SpamShield

Home | Site Design | Banner Design | Code Den | Offsite Posts | Downloads | Photography | About Hanan | Hanan's CV | Contact Hanan
Copyright © 2009 Hanan Schwartzberg. All rights reserved.