禁用单个控件的EventValidation,可以吗? [英] Disable EventValidation for single control, is it possible?

查看:91
本文介绍了禁用单个控件的EventValidation,可以吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我知道这是一个争议很大的话题,通常在您将其作为解决方案考虑时,您可能需要重新考虑UI逻辑.

I know this is a very debated topic, and usually when you are thinking about this as a solution you might want to rethink your UI logic.

我知道我可以使用ClientScriptManager.RegisterForEventValidation通过验证.但是,我真的很想知道.是否可以删除单个控件的事件验证?有办法解决这个问题吗?

I know I can pass validation using ClientScriptManager.RegisterForEventValidation. But, I'd really like to know. Is it possible to remove event validation for a single control? Is there a way work around for this?

我正在渲染呈现后从客户端修改DropDownList.

I'm modifying a DropDownList, from the client side after it's rendered.

推荐答案

您的问题的简短答案是:不,没有办法这样做.您必须为整个页面禁用EventValidation.

The short answer to your question is: No, there is no way to do this. You must disable EventValidation for the entire page.

有多种解决方法...如果您确实不想禁用EventValidation,则将选定的值存储在隐藏字段中并恢复DropDownList的状态(或者也许只是清除选择?).

There are various workarounds... If you really don't want to disable EventValidation, store the selected value in a hidden field and restore the state of the DropDownList (or maybe just clear selection?).

如果需要在客户端添加所有的值,则无论如何都必须使用其他方法将其发送出去,因为它们不会出现在服务器端控件中.这些值未发布!

If you need all the values added client-side, you have to send those up using some other method anyway, because they will not be present in the server-side control. Those values are not posted!

这篇关于禁用单个控件的EventValidation,可以吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆