ICallbackEventHandler and "Invalid postback or callback argument" error

Discussion in 'ASP .Net' started by Martin, Jun 14, 2006.

  1. Martin

    Martin Guest

    Hi,

    I have an aspx page with two dropdownlist controls.
    I update the options in the second ddl based on selection made in the first.

    I do this with the ICallbackEventHandler interface, as per "Implementing
    Client Callbacks Without Postbacks in ASP.NET Web Pages"
    (http://msdn2.microsoft.com/en-us/library/ms178208.aspx)

    This works.
    However I now want to process the selection subsequently made in the second
    ddl, when a button web server control is pressed, caused a normal postback.

    When I click the button, I get 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. "

    I believe it is refering to the SelectedIndexChanged event on the second
    ddl, which itself does not cause a postback, but should be processed on an
    eventual postback (in this case the button.click).

    In a nutshell, I'm not clear where to place my call to
    RegisterForEventValidation, nor whether/where I should call ValidateEvent.

    The example at How to: Implement Callbacks in ASP.NET Web Pages at
    http://msdn2.microsoft.com/en-us/library/ms366518(d=ide).aspx doesn't match
    my scenario.

    Any help much appreciated.

    Thanks
    Martin
     
    Martin, Jun 14, 2006
    #1
    1. Advertising

  2. Martin

    Martin Guest

    Thinking about this, I think the plan is flawed in having the second ddl
    being a server control I expect to process on postback. Primarily because I
    don't think there is a model for the options in the dropdownlist changing on
    the *client* side. The selected value I want to processs doesn't exist on
    the server side.

    My plan now is to populate a hidden field when the second ddl changes (all
    on the client side), then process the hidden field's ValueChanged event when
    I get back to the server.

    Comments from those who've been here before??

    Thanks again
    Martin

    "Martin" <> wrote in message
    news:...
    > Hi,
    >
    > I have an aspx page with two dropdownlist controls.
    > I update the options in the second ddl based on selection made in the
    > first.
    >
    > I do this with the ICallbackEventHandler interface, as per "Implementing
    > Client Callbacks Without Postbacks in ASP.NET Web Pages"
    > (http://msdn2.microsoft.com/en-us/library/ms178208.aspx)
    >
    > This works.
    > However I now want to process the selection subsequently made in the
    > second ddl, when a button web server control is pressed, caused a normal
    > postback.
    >
    > When I click the button, I get 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.
    > "
    >
    > I believe it is refering to the SelectedIndexChanged event on the second
    > ddl, which itself does not cause a postback, but should be processed on an
    > eventual postback (in this case the button.click).
    >
    > In a nutshell, I'm not clear where to place my call to
    > RegisterForEventValidation, nor whether/where I should call ValidateEvent.
    >
    > The example at How to: Implement Callbacks in ASP.NET Web Pages at
    > http://msdn2.microsoft.com/en-us/library/ms366518(d=ide).aspx doesn't
    > match my scenario.
    >
    > Any help much appreciated.
    >
    > Thanks
    > Martin
    >
     
    Martin, Jun 14, 2006
    #2
    1. Advertising

  3. Event validation checks that postback data came from a control that was
    enabled at render, and if a control with a know list of values, the the
    posted value is one of the know values. if you have client script change the
    list of values of a dropdown, then you need to disable the default event
    validation. as the error message explains, you can either turn it off, or
    register you own validation routine for the effected controls.


    -- bruce (sqlwork.com)


    "Martin" <> wrote in message
    news:...
    > Hi,
    >
    > I have an aspx page with two dropdownlist controls.
    > I update the options in the second ddl based on selection made in the
    > first.
    >
    > I do this with the ICallbackEventHandler interface, as per "Implementing
    > Client Callbacks Without Postbacks in ASP.NET Web Pages"
    > (http://msdn2.microsoft.com/en-us/library/ms178208.aspx)
    >
    > This works.
    > However I now want to process the selection subsequently made in the
    > second ddl, when a button web server control is pressed, caused a normal
    > postback.
    >
    > When I click the button, I get 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.
    > "
    >
    > I believe it is refering to the SelectedIndexChanged event on the second
    > ddl, which itself does not cause a postback, but should be processed on an
    > eventual postback (in this case the button.click).
    >
    > In a nutshell, I'm not clear where to place my call to
    > RegisterForEventValidation, nor whether/where I should call ValidateEvent.
    >
    > The example at How to: Implement Callbacks in ASP.NET Web Pages at
    > http://msdn2.microsoft.com/en-us/library/ms366518(d=ide).aspx doesn't
    > match my scenario.
    >
    > Any help much appreciated.
    >
    > Thanks
    > Martin
    >
     
    bruce barker \(sqlwork.com\), Jun 14, 2006
    #3
  4. Martin

    Martin Guest

    Thanks Bruce,

    I'm working around this at present, but will come back to it at some point.

    Martin
    "bruce barker (sqlwork.com)" <> wrote
    in message news:e%...
    > Event validation checks that postback data came from a control that was
    > enabled at render, and if a control with a know list of values, the the
    > posted value is one of the know values. if you have client script change
    > the list of values of a dropdown, then you need to disable the default
    > event validation. as the error message explains, you can either turn it
    > off, or register you own validation routine for the effected controls.
    >
    >
    > -- bruce (sqlwork.com)
    >
    >
    > "Martin" <> wrote in message
    > news:...
    >> Hi,
    >>
    >> I have an aspx page with two dropdownlist controls.
    >> I update the options in the second ddl based on selection made in the
    >> first.
    >>
    >> I do this with the ICallbackEventHandler interface, as per "Implementing
    >> Client Callbacks Without Postbacks in ASP.NET Web Pages"
    >> (http://msdn2.microsoft.com/en-us/library/ms178208.aspx)
    >>
    >> This works.
    >> However I now want to process the selection subsequently made in the
    >> second ddl, when a button web server control is pressed, caused a normal
    >> postback.
    >>
    >> When I click the button, I get 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. "
    >>
    >> I believe it is refering to the SelectedIndexChanged event on the second
    >> ddl, which itself does not cause a postback, but should be processed on
    >> an eventual postback (in this case the button.click).
    >>
    >> In a nutshell, I'm not clear where to place my call to
    >> RegisterForEventValidation, nor whether/where I should call
    >> ValidateEvent.
    >>
    >> The example at How to: Implement Callbacks in ASP.NET Web Pages at
    >> http://msdn2.microsoft.com/en-us/library/ms366518(d=ide).aspx doesn't
    >> match my scenario.
    >>
    >> Any help much appreciated.
    >>
    >> Thanks
    >> Martin
    >>

    >
    >
     
    Martin, Jun 15, 2006
    #4
    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. Replies:
    0
    Views:
    539
  2. Replies:
    2
    Views:
    1,127
  3. =?Utf-8?B?SWJyYWhpbS4=?=

    Invalid postback or callback argument Error

    =?Utf-8?B?SWJyYWhpbS4=?=, Jun 26, 2006, in forum: ASP .Net
    Replies:
    1
    Views:
    1,504
    bruce barker \(sqlwork.com\)
    Jun 26, 2006
  4. Nathan Sokalski

    Invalid postback or callback argument error

    Nathan Sokalski, Jan 9, 2007, in forum: ASP .Net
    Replies:
    2
    Views:
    17,413
    Cor Ligthert [MVP]
    Jan 10, 2007
  5. shapper
    Replies:
    1
    Views:
    557
    Jonathan Wood
    Feb 1, 2008
Loading...

Share This Page