验证器在回发发生后不进行验证 [英] Validators do not Validate after postback occurs

查看:17
本文介绍了验证器在回发发生后不进行验证的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我找到了问题的根源,我没有很好地解释它.

I found the source of the issue i did not explain it very well.

基本上我有一个带有比较验证器的表单,可确保我的 txtstartdate 不小于我的 txtenddate.所以这 2 个文本框附有 ajax 日历,当我选择那 2 个时,我的比较验证器出现并给出错误.

Basically i have a form with a compare validator that makes sure my txtstartdate is not less than my txtenddate. So these 2 text boxes have ajax calendar attached to it and when I select those 2 my compare validator appears and gives an error.

然后我有 2 个下拉列表 ddlroom,ddlnumber.ddlroom 启用了自动回发,所以如果我在开始日期之前错误地填充我的日历,比较验证器会触发比较验证器,但是第二次我选择一个房间名称,自动回​​发发生并且验证器消失,我可以单击插入按钮,它将插入任何日期在没有验证的文本框中.希望能解释的好一点抱歉

Then i have 2 dropdownlist ddlroom, ddlnumber. ddlroom has autopostback enabled so if i populate my calendar incorrectly having my endate before startdate the comparevalidator fires however the second i select a roomname the autopostback occurs and the validator dissapears and I am able to click the insert button and it will insert what ever date is in the textboxes without validating. Hope that explains a little better sorry

推荐答案

如果您希望在 DropDownList 执行回发时触发验证,请确保在 DropDownList 上设置 CausesValidation="true".

If you want validation to fire when your DropDownList does a postback then be sure to set CausesValidation="true" on the DropDownList.

这篇关于验证器在回发发生后不进行验证的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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