我需要用户选择组合框,然后才能保存或执行任何其他操作. [英] i need the user to select combobox before he can save or do any other operations.
本文介绍了我需要用户选择组合框,然后才能保存或执行任何其他操作.的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我的内容页面上有一个组合框.
我想对组合框使用验证并将其结果作为布尔值发送到我的母版页,因为我在母版页上有一个返回类型为bool的方法.
我需要用户选择组合框,然后才能保存或执行任何其他操作.
我在网上搜索,但没有很好的例子.
I have a combobox in my content page.
I want to use validation for combobox & send its result as boolean to my master page because I have a method on master page which returns type as bool.
I need the user to select combobox before he can save or do any other operations.
I searched the net but didn''t get good examples.
推荐答案
如果可能,请使用RequiredFieldValidator
.在其他情况下,您可以配置和使用CustomValidator
,因为您自己编写验证逻辑,所以更灵活.
UseRequiredFieldValidator
if it''s possible. In other cases you can configure and useCustomValidator
which is more flexible cause you write your validation logic yourself.
尝试此
try this
<asp:RequiredFieldValidator ID="rfv_Users" ControlToValidate="ddl_UserList" runat="server" ErrorMessage="Country"
SetFocusOnError="true" InitialValue="Select" Display="dynamic">*</asp:RequiredFieldValidator>
给您的下拉列表0索引值作为选择
dropdown.items.insert(0,"Select");
give your dropdown 0 index value as select
dropdown.items.insert(0,"Select");
这篇关于我需要用户选择组合框,然后才能保存或执行任何其他操作.的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文