禁用单个控件的EventValidation,可以吗?

编程入门 行业动态 更新时间:2024-10-08 19:51:06
本文介绍了禁用单个控件的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,可以吗?

本文发布于:2023-11-13 02:41:29,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1583198.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:控件   EventValidation

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!