Invalid postback or callback argument.

Rate It (4)

Last post 09-10-2009 11:11 AM by spankster. 181 replies.

Sort Posts:

  • Re: Invalid postback or callback argument.

    03-25-2008, 9:42 AM
    Locked
    • Member
      27 point Member
    • Mr Baldman
    • Member since 11-08-2007, 12:52 PM
    • Nottingham UK
    • Posts 26

    ReTox:
    nobody tried something like this? 

    		protected override void Render(HtmlTextWriter writer)
    		{
    			Register(this);
    			base.Render(writer);
    		}
    
    		private void Register(Control ctrl)
    		{
    			foreach (Control c in ctrl.Controls)
    				Register(c);
    			Page.ClientScript.RegisterForEventValidation(ctrl.UniqueID);
    		}

     

    I didn't test it with any AJAX, but for regular pages it works so far.

     

     I have deployed this fix on 2 of my major sites - works a treat.
    Thanks to retox
     

  • Re: Invalid postback or callback argument.

    04-01-2008, 6:25 AM
    Locked
    • Member
      287 point Member
    • julesr
    • Member since 06-20-2002, 4:34 PM
    • Powys, Wales
    • Posts 58

    Bizarrely, the code below generates the infamous callback error when 2 is selected from the list. Removing vbcrlf from the code 'fixes' it.

     

     <%@ Page Language="VB"%>
    <script runat="server">  
        Sub Page_Load(ByVal sender As Object, ByVal e As EventArgs)
            Dim Arr As String() = {1, 2 & vbCrLf, 3}
            DropDownList1.DataSource = Arr
            DropDownList1.DataBind()
        End Sub
    </script>
    <form runat="server">
        <asp:DropDownList ID="DropDownList1" runat="server"/>
          <asp:Button ID="Button1" runat="server" Text="Submit" />
        </form>

  • Re: Invalid postback or callback argument.

    04-03-2008, 4:40 PM
    Locked
    • Member
      92 point Member
    • Shodan240z
    • Member since 04-03-2008, 7:58 PM
    • Posts 11

    ReTox:
    nobody tried something like this? 

    		protected override void Render(HtmlTextWriter writer)
    		{
    			Register(this);
    			base.Render(writer);
    		}
    
    		private void Register(Control ctrl)
    		{
    			foreach (Control c in ctrl.Controls)
    				Register(c);
    			Page.ClientScript.RegisterForEventValidation(ctrl.UniqueID);
    		}

     

    I didn't test it with any AJAX, but for regular pages it works so far.

     

    I've used this on pages *with* ajax, and it works perfectly there as well.

    Thanks so much for this! 

    "Give a man a fire and he'll stay warm for a day.
    Set a man on fire and he'll stay warm for the rest of his life."
  • Re: Invalid postback or callback argument.

    04-04-2008, 4:00 AM
    Locked
    • Member
      4 point Member
    • niranjan2u
    • Member since 04-04-2008, 7:48 AM
    • Posts 2

    Hi,

    I also have the same problem. I have no problem if the button is clicked when the page is fully loaded in the browser. But if clicks when the page is loading, getting the same exception. I have used the clientscript.RegisterForEventValidation, not resolved my problem. Help me out of this.....

  • Re: Invalid postback or callback argument.

    04-21-2008, 5:35 AM
    Locked
    • Member
      10 point Member
    • UydurukAdres
    • Member since 05-20-2007, 6:26 PM
    • Ankara, Turkey
    • Posts 5

    I had that problem in a page that contained a gridview component which had a datasource filtered according to a parameter obtained from querystring. If i used postback check method in form load event to disable duplicate databinding then all data in table was listed when i clicked Edit, Cancel, Update, Delete buttons in any row as no filter was being applied when the form was reloaded.

    I solved that problem using these steps:

    1. I checked ispostback variable to disable multiple databinding in form load event
    2. I rebinded the control in gridview's RowCanceling, RowDeleted and RowEditing events.

    In other words i ran the code to recreate SQL statement for data source using querystring parameter and rebind gridview under above listed events.

    I hope this helps people who is changing datasource during run-time and having that silly problem.

    Yalin Meric
    Software Projects Coordinator
    Ebit Informatics Inc.
    www.e-bit.com.tr

    www.e-bit.com.tr
    www.onspeedtr.com
    www.sagligimizicin.com
    www.hukukyazilim.com
  • Re: Invalid postback or callback argument.

    04-25-2008, 9:02 AM
    Locked
    • Participant
      1,708 point Participant
    • mvang
    • Member since 12-27-2007, 6:59 PM
    • Mid West
    • Posts 361

    This is a good article covering this problem:

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

    "If you have knowledge, let others light their candles in it."
    — Margaret Fuller
  • Re: Invalid postback or callback argument.

    04-25-2008, 10:10 AM
    Locked
    • Member
      7 point Member
    • s.foschi
    • Member since 05-23-2007, 1:09 PM
    • Posts 5
    I got the same error:
    Invalid postback or callback argument. Event validation is enabled using <PAGES enableEventValidation="true"></PAGES>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.
    and in my case i came to the conclusion that was a logical error in my code.

    I was trying to do this :

    Protected Sub dtaLingue_ItemCommand(ByVal source As Object, ByVal e As System.Web.UI.WebControls.DataListCommandEventArgs) Handles dtaLingue.ItemCommand

    Session("idLingua") =Trim(CType(e.Item.Controls(2), Label).Text)

    End Sub

    but in my case, the correct way is this one:

    Protected Sub dtaLingue_ItemCommand(ByVal source As Object, ByVal e As System.Web.UI.WebControls.DataListCommandEventArgs) Handles dtaLingue.ItemCommand

    Session("idLingua") = Trim(CType(CType(CType(source, DataList).Controls(1), DataListItem).FindControl("lblIdLingua"), Label).Text)

    End Sub

    So i came to the conclusion that one of the reasons of this error is also an incorrect logic in the application.
  • Re: Invalid postback or callback argument.

    04-25-2008, 11:49 AM
    Locked
    • Member
      2 point Member
    • jimmjobs
    • Member since 04-25-2008, 3:48 PM
    • Posts 1

    Mine was an extra FORM tag.... check for this doh!

  • Re: Invalid postback or callback argument.

    04-25-2008, 1:06 PM
    Locked
    • Participant
      1,708 point Participant
    • mvang
    • Member since 12-27-2007, 6:59 PM
    • Mid West
    • Posts 361

    My problem relates to the article that I posted earlier where I was attempting to add a value from client script to an asp drop down control in which the application thinks I am performing an injection attack. My question is, if I create a custom drop down control and called it namespace MyDropDownControl, if I leave out the attribute [SupportEventsValidation] can and will my control override that portion of the dropdown?

    The reason for me asking is because I don't want to diable the page event validation but the solution was to register my value to the control upon Render, in which I can only do that if the value was already known. In my case, it's whatever value the user will enter and add. Therefore, if it is possible, my class will disable the event validation for just that instance of my class rather than the whole page. Any comments, suggestions, or knowledge about this?

    Thanks everyone! :)

    "If you have knowledge, let others light their candles in it."
    — Margaret Fuller
  • Re: Invalid postback or callback argument.

    04-27-2008, 10:10 AM
    Locked
    • Member
      79 point Member
    • Ensonix
    • Member since 07-18-2005, 7:31 PM
    • California
    • Posts 26

    I was encountering this problem when users were clicking on links or buttons before the page had finished loading, then I finally found this blog post http://blogs.msdn.com/tom/archive/2008/03/14/validation-of-viewstate-mac-failed-error.aspx

    Solution 3 on this page solved the problem for me, moving the EVENTVALIDATION field to the top of the page.

    Ryan 

    Filed under:
  • Re: Invalid postback or callback argument.

    04-30-2008, 3:30 AM
    Locked
    • Member
      34 point Member
    • dbrook007
    • Member since 10-30-2006, 8:59 PM
    • Posts 38

    I have been receiving this error:

    " 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.  "

    This has only been experienced by users who have been using the website whilst the same page has been updated.  It has been reported occasionally during busy times too.  The problem arises from a asp.net 2.0 drop-down control that is in an Ajax Update Panel (i.e., when a user selects an item from it).  But, it only occurs in the scenario I have described.

    This occurs usually from users using Firefox, though it has occurred sometimes with IE7 users.  However, I can only recreate the problem in Firefox. 

    I've tried a number of possible solutions using the ClientScriptManager.RegisterForEventValidation, but none have solved this problem.  Changing <%@ Page EnableEventValidation = "false" %> has temporarily solved the problem, but I don't really want this solution long term.

    The project is an ASP.Net 2.0 AJAX enabled website.  It uses masterpages. 

    Any help on this appreciated.

    Thanks - Darren

     

    Darren Brook
    e: darrenbrook@btconnect.com
  • Re: Invalid postback or callback argument.

    05-06-2008, 12:01 PM
    Locked
    • Member
      10 point Member
    • raddrick
    • Member since 11-13-2007, 5:35 PM
    • Posts 13
    YEA! i was converting an asp to aspx, didnt see that extra 'form' tag
    =D
    TY!!!!
    Rick Graham
    System Developer
  • Yes [Yes] Re: Invalid postback or callback argument.

    05-20-2008, 11:14 PM
    Locked
    • Member
      2 point Member
    • Khushi.net
    • Member since 05-21-2008, 2:37 AM
    • Australia
    • Posts 1

    Anyplatform:

    I know this is a little late since it's been a while since your post; however, I hate it when forums are not updated...

    If you are doing databinding in the load event of the page, and you are getting this problem, make sure that you check to make sure it's not a postback by wraping it in an if block.  I had this problem after I added some client code to send a confirmation popup.

    if(!IsPostBack)
    {

          BindData();
    }

    Hope this helps..

     

    Hi there Big Smile

    Thanks for this post, u r a life saver. i have been getting this error "invalid postback or callback argument & blah blah......" ever since i migrated my code from asp.net 1.0 to asp.net 2.0. by this time i was in complete frustation because i had tried everything found on the net like setting 'enableeventvalidation' to false in page directive & check which control was giving the error but nothing seemed to be working. The funny thing was same code was working well for other screens & that made me curious until i read ur post.

    I forgot to check in my page load that i was actually binding the data to the grid on postback inside the page load event. thanks a lot for this Idea

    For those having the same error on postback with or without a popup on ur page please make to check for postback before u bind the data to the grid.

    if !page.ispostback then

    grid.databind()

    end if

    I hope this thread helps to everyone who are receiving this error at any time in their code.Yes

  • Re: Invalid postback or callback argument.

    05-29-2008, 8:49 AM
    Locked
    • Member
      22 point Member
    • ketan patel
    • Member since 05-28-2008, 4:18 PM
    • Posts 6

     

    To Solve This Problem What You Have to Do Just Write Following Code in Web.Config. system.web> Doing this One It’s Solve Your Problem But It’s Effect On Your Site Security. Basically EnableeventValidation of asp.Net pages are ture.Wich Prevent Injection Attack.Make it’s False Involve This Injection Attack.

     

    http://webaspdotnet.blogspot.com/

  • Re: Invalid postback or callback argument.

    05-29-2008, 1:29 PM
    Locked
    • Member
      2 point Member
    • Stevenzook
    • Member since 05-29-2008, 5:27 PM
    • Posts 1

    Thank you Alle!

     You solved my problem with this exception! All i had to do on my <asp:GridView> was set enableViewState="false" and suddenly that ugly error went away!

    I admit to being new to C# and these little things really get me pulling my hair out.

     

    -Steven

Page 10 of 13 (182 items) « First ... < Previous 8 9 10 11 12 Next > ... Last »