views:

101

answers:

1

When hitting a button, an error would occur:

System.Web.HttpUnhandledException: Exception of type 'System.Web.HttpUnhandledException' was thrown. ---> System.ArgumentException: Invalid postback or callback argument. Event validation is enabled using in configuration or 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 then added EnableEventValidation="false" into my @Page directive, which fixed the error. Now after manipulating the listbox, the new values in the listbox are not posted back to the server. How can I solve this?

A: 

You can benefit from those features by leaving it enabled then register your control for event validation. Simply add the following call in the PreRender or Render page life cycle then your control should work without having to turn off eventValidation:

  Page.ClientScript.RegisterForEventValidation(this.UniqueID);
XGreen
I tried and still get the original error. What else can I try?
Peter
There is also this post which I think would be helpful to youhttp://stackoverflow.com/questions/228969/asp-net-invalid-postback-or-callback-argument-event-validation-is-enabled-usi
XGreen