验证下拉列表 [英] Validation for dropdownlist

查看:81
本文介绍了验证下拉列表的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个绑定到数据库的下拉列表.我在其中插入了选择-语言"项以进行默认设置(dropdownlist1.items.insert(0,选择-语言").我希望当用户选择选择-语言并单击提交按钮或selectedindex之后发生验证更改出现请选择langauge的消息,否则您将无法选择langauge.

thanx.

I have dropdownlist that is bind to database. i insert "choose--langauge" item in it for defaul(dropdownlist1.items.insert(0,"choose--langauge"). i want when user select choose--langauge and after click submit button or selectedindex change than validation occur with messsage that Please select langauge or you cannot select choose langauge.

thanx.

推荐答案

我认为,您是在页面加载本身中设置初始值.
因此,每当页面回发时,选定的索引就会设置为默认值0.

放入if条件检查邮包
例如:if(Page.IsPostback)

尝试: http://www.sforsearch.com/FPGHG [
I think, you are setting the intial value in page load itself.
So, whenever the page is posted back, selected index is set to default vaue 0.

Put a if condition to check post pack
Ex: if (Page.IsPostback)

Try : http://www.sforsearch.com/FPGHG[^]


为此,请使用必填字段验证器并将其控件设置为validate属性,并将其设置为DropDownlist1和将初始值设置为选择--langauge

它将为您提供帮助
For that please take a required field validator and set its control to validate property to DropDownlist1 and Set Initial Value as choose--langauge

It will help You


您可以使用javascript进行验证.
You can use javascript for validation.


这篇关于验证下拉列表的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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