验证:他们在回发保持禁用时禁用客户方? [英] Validators: Do they Stay disabled on postback when disabled ClientSide?

查看:124
本文介绍了验证:他们在回发保持禁用时禁用客户方?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我一直在学习了很多关于标准asp.net验证器,而我的最新发现是有关如何禁用的验证客户端,这是pretty凉爽。

I have been learning alot about the standard asp.net Validators, and my latest discovery was about how to disable a validator client side, which was pretty cool.

现在,如果我的初始后启用了验证,但客户端,我禁用它,并在服务器端识别客户端的变化,并保持它,或者它得到重新启用页面被送回用户?

now, if my initial post has the validator enabled, but client side, i disable it, does the server side recognize the client side change, and keep it, or does it get re-enabled the the page is sent back to the user?

谢谢!

内特

推荐答案

.NET服务器端验证程序控件将被重置到任何他们已经确定回传过程中服务器端code到最后。

.NET Server side validator controls will be reset to whatever they have been set to last in the server side code during a postback.

所以,举例来说,如果你设置了必填字段验证器rqvControl.enabled =在它的.aspx标记真,那么回发后,将不管其状态是客户端启用。

So for example if you have set a required field validator to rqvControl.enabled = true in its .aspx tag, then after a postback it will be enabled no matter what its state was client side.

如果您要设置在客户端验证器的状态,你要坚持它,那么你将需要设置,你可以回传过程中您的服务器code读取值。这可以像设置您的JavaScript是做启用/禁用操作的隐藏字段值一样简单。在您的codebehind只是处理基于您的验证程序的启用状态关闭在您的隐藏字段的值。

If you are setting the state of a validator on the client side, and you want to persist it, then you will need to set a value that you can read in your server code during a postback. This can be as simple as setting a hidden field value from your javascript that is doing the enable/disable operation. In your codebehind just handle the enabled state of your validator based off the value in your hidden field.

这篇关于验证:他们在回发保持禁用时禁用客户方?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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