通过TextChanged事件回发到文本框后提交表单时,RequiredFieldValidator不起作用 [英] RequiredFieldValidator doesn't work when submitting form after Posting back by TextChanged event to the Textbox

查看:112
本文介绍了通过TextChanged事件回发到文本框后提交表单时,RequiredFieldValidator不起作用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在我的 .aspx 表单中,我有一个带有 Autopostback = True 的文本框。
我还在它旁边设置了RequiredFieldValidator。但是,当通过文本框的TextChanged事件回发时,我的RequiredFieldValidator出现了,但仍然可以在文本框中不带任何内容的情况下提交表单!

In my .aspx form I have a text box with Autopostback=True. I also set a RequiredFieldValidator next to it. But when Posting back by TextChanged event of my text box, my RequiredFieldValidator appears but still I can submit my form with nothing in the text box!

怎么了,怎么了?我可以解决这个问题吗?

What is wrong, and how can I fix this?

推荐答案

您必须将文本框的CausesValidation属性设置为true(对于文本框,默认设置为false)

You have to set the textbox's CausesValidation property to true (it's set to false by default for textboxes).

这篇关于通过TextChanged事件回发到文本框后提交表单时,RequiredFieldValidator不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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