ICallbackEventHandler and "Invalid postback or callback argument" error

M

Martin

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
 
M

Martin

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
 
B

bruce barker \(sqlwork.com\)

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)
 
M

Martin

Thanks Bruce,

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

Martin
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,994
Messages
2,570,223
Members
46,812
Latest member
GracielaWa

Latest Threads

Top