Custom postback code and RegsiterForEventValidation

A

Andreas Bergmeier

Hi.
Is there some KB article how to use EnableEventValidation when doing
customized posts? Basicly we're building a post string via javascript
and issue it via means of XMLHttpRequest to the server.
This worked fine in .NET 1.1

Now in ASP.NET 2.0 I get an error message: '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.'

But even after I add the RegisterForEventValidation call I still get
this error message. So I'd be interested in what one has to do to setup
ones' code for postback to the server. (I didn't yet disassemble the
asp.net code).

Regards
Andreas
 
B

bruce barker

event validation checks that only enabled and rendered (visible)
controls (status stored in viewstate) and with eventhandlers are posting
back for event handling. for controls with a know set of values (say a
drop down) asp.net also checks the value is in range. this is
implemented for several built in controls.

registerforeventvalidation allows you to add this feature to your own
custom controls. it must be called during render and once for every
legal postback value (clientid,value), once to allow clientpostback
(clientid).

you can turn this feature off at site (web config) or page level with
EnableEventValidation.

-- bruce (sqlwork.com)
 

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,582
Members
45,066
Latest member
VytoKetoReviews

Latest Threads

Top