ClientScriptManager.RegisterForEventValidation trouble

Z

Zac

Hello!

Maybe someone out there can point me int he correct direction for a
fix to a problem I'm having. I've setup a user control with two list
boxes. One starts with a full list of items, the other one completely
empty. I've setup a client-side javascript function that allows the
user to move items from one list box to the other and back as a way of
'selecting' which options they want. The user control is set in a
server side form. When I click the save button that posts back to the
server, I get the following 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've been researching the problem on Google for a while now but just
can't seem to find an example that is similar to what I'm doing, works
with what I'm doing, or offers a clear explanations of what I need to
do to make it work. Can anyone out there point me to some good
resources, or even just in the right direction?

Thanks!
Zac
 
G

Guest

to prevent hacking, asp.net checks that the postback value for a listbox was
included in the original list. thus your error.

as the error implies, you can turn off EventValidation on the page.
(Page.EnableEventValidation = false)

if you write your own control, and want it to have its data also validated
you use RegisterForEventValidation. its not used for turning off validation,
only to add it.

if you don't want to disable for the page, in OnInit you can add the new
postback value to the listbox, and it will pass the test.

-- bruce (sqlwork.com)
 
Z

Zac

to prevent hacking, asp.net checks that the postback value for a listbox was
included in the original list. thus your error.

as the error implies, you can turn off EventValidation on the page.
(Page.EnableEventValidation = false)

if you write your own control, and want it to have its data also validated
you use RegisterForEventValidation. its not used for turning off validation,
only to add it.

if you don't want to disable for the page, in OnInit you can add the new
postback value to the listbox, and it will pass the test.

-- bruce (sqlwork.com)

Thank you for the reply Bruce, Could you explain the OnInit way a
little deeper?
 
Z

Zac

to prevent hacking, asp.net checks that the postback value for a listbox was
included in the original list. thus your error.

as the error implies, you can turn off EventValidation on the page.
(Page.EnableEventValidation = false)

if you write your own control, and want it to have its data also validated
you use RegisterForEventValidation. its not used for turning off validation,
only to add it.

if you don't want to disable for the page, in OnInit you can add the new
postback value to the listbox, and it will pass the test.

-- bruce (sqlwork.com)

Thank you for the reply Bruce, Could you explain the OnInit way a
little deeper?
 
Z

Zac

to prevent hacking, asp.net checks that the postback value for a listbox was
included in the original list. thus your error.

as the error implies, you can turn off EventValidation on the page.
(Page.EnableEventValidation = false)

if you write your own control, and want it to have its data also validated
you use RegisterForEventValidation. its not used for turning off validation,
only to add it.

if you don't want to disable for the page, in OnInit you can add the new
postback value to the listbox, and it will pass the test.

-- bruce (sqlwork.com)

Thank you for the reply Bruce. Could I talk you into elaborating a
little about the OnInit way?
 

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

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,054
Latest member
TrimKetoBoost

Latest Threads

Top