ASPX自定义验证器禁止从DropDownList中进行某些选择 [英] ASPX Custom Validator to Prohibit Certain Selections From A DropDownList

查看:108
本文介绍了ASPX自定义验证器禁止从DropDownList中进行某些选择的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个包含几个选项的下拉列表,但是我需要有一个自定义验证器,该验证器不允许用户在下拉列表中选择4个潜在选项.任何帮助将不胜感激.

I have a drop down list that has several options in it but I need to have a custom validator which does not allow the user to select 4 of the potential options in the drop down list. Any help would be greatly appreciated.

推荐答案

首先,即使您实现了这种行为,也不能将其称为验证器". 验证器"是一种在输入数据后对其进行验证的东西,但是您想过滤掉输入(选择)本身.

我担心这种行为与预期的UI行为相距太远,并且会造成混乱.实施它也会有问题.

有一个众所周知的等效UI演示,具有相同的逻辑:一组单选按钮.如果控制每个单选按钮的Enabled属性,则可以根据其他数据启用或禁用其中的某些功能,从而以所需的方式有效过滤输入.

请参阅 http://msdn.microsoft.com/en-us/library /system.web.ui.webcontrols.radiobutton.aspx [ ^ ].

—SA
First of all, even if you implement such behavior, it cannot be called "validator". A "validator" is something which validates data after it is entered, but you want to filter out the input (selection) itself.

I fear to say such behavior is too far from expected UI behavior and would be very confusing. Implementation of it would be problematic, too.

There is a well-known equivalent UI presentation with the same logic: a set of radio buttons. If you control Enabled property of each radio button, you can enable or disable some of them depending on other data, effectively filtering the input the way you want.

See http://msdn.microsoft.com/en-us/library/system.web.ui.webcontrols.radiobutton.aspx[^].

—SA


这篇关于ASPX自定义验证器禁止从DropDownList中进行某些选择的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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