开发者

Modifying listbox values with jQuery in WebForm not posting back

开发者 https://www.devze.com 2022-12-29 10:55 出处:网络
When hitting a button, an error would occur: System.Web.HttpUnhandledException: Exception of type \'System.Web.HttpUnhandledException\' was thrown. ---> System.ArgumentException: Invalid postback or

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 val开发者_高级运维idation 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?


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);
0

精彩评论

暂无评论...
验证码 换一张
取 消