Error on post back

Discussion in 'ASP .Net' started by Wayne Sepega, Jan 9, 2006.

  1. Wayne Sepega

    Wayne Sepega Guest

    I have two drop downs on my web form. The contents of DropDown2 depends on
    what is currently selected in DropDown1. I use client side java script to
    re-populate DropDown2 whenever DropDown1 changes.

    In doing so, if I select a value in DropDown2 that wasn't there when the
    page was built I receive the following error:

    Exception Details: System.ArgumentException: 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.

    I have tried doing the following:

    protected override void Render(HtmlTextWriter writer)
    {
    DateTime curDate;
    int dateCount = br.MaxPickUpDateDays + br.MaxExpirationDays;

    if (subscription.ExpirationDate <= DateTime.Now.Date)
    ClientScript.RegisterForEventValidation("DropDown2",
    subscription.ExpirationDate.ToString(DateFormat));

    for (int i = 0; i < dateCount; i++)
    {
    curDate = System.DateTime.Now.AddDays(i).Date;
    ClientScript.RegisterForEventValidation("DropDown2",
    curDate.ToString(DateFormat));
    }
    base.Render(writer);
    }


    However, when I do the above my DropDown2.SelectedValue always comes back
    blank.

    I've spent about an hr or so working on this and searching google, but all
    the examples I find give me back a blank selected value. A point in the
    right direction or some suggestions would be appreciated.

    Thanks
    Wayne Sepega
     
    Wayne Sepega, Jan 9, 2006
    #1
    1. Advertising

  2. if the problem is with the validation, have you tryed to set it to off?
    enableEventValidation="false"
     
    Henrique Mello, Jan 9, 2006
    #2
    1. Advertising

  3. Wayne Sepega

    Wayne Sepega Guest

    No, but given that it's set to true for security reasons and I would like to
    make use of the feature it provides, I did not want to set it to false.

    I would rather know why the ClientScript.RegisterForEventValidation is not
    working like I understand it should.

    Thanks
    Wayne


    "Henrique Mello" <> wrote in message
    news:...
    > if the problem is with the validation, have you tryed to set it to off?
    > enableEventValidation="false"
    >
     
    Wayne Sepega, Jan 10, 2006
    #3
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Joby
    Replies:
    0
    Views:
    1,662
  2. sylvia sil
    Replies:
    1
    Views:
    648
    Curt_C [MVP]
    Dec 29, 2004
  3. =?Utf-8?B?Z29yaWxsYQ==?=
    Replies:
    1
    Views:
    818
    Masudur
    May 25, 2007
  4. Author
    Replies:
    6
    Views:
    3,251
    George
    Jan 22, 2009
  5. martin

    Reading a file twice, back to back ?

    martin, Apr 16, 2006, in forum: Perl Misc
    Replies:
    16
    Views:
    171
Loading...

Share This Page