必填字段验证器,在显示初始页面加载 [英] Required Field Validator, displaying on initial page load

查看:114
本文介绍了必填字段验证器,在显示初始页面加载的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个连接到结束,然后在页面底部即显示在验证摘要必填字段验证控件一个简单的文本框。一切正常就可以了伟大的,但似乎验证火页面上的这明显衬托要求的验证和显示错误消息的初始负载。

I have a simple textbox with a required field validation control attached to end and then being displayed in a validation summary at that bottom of the page. Everything works great on it but the validation seems to fire on the page's initial load which obviously sets off the required validation and displays the error message.

我如何设置此控件只验证表单提交后?

How do I set this control to only validate after the form has been submitted?

推荐答案

这听起来像你在你的页面加载code是这样的:

It sounds like you have code in your page load like this:

if (!Page.IsValid()) //...

您真正需要的是这样的:

What you really want is this:

if (Page.IsPostBack && !Page.IsValid()) //...

这篇关于必填字段验证器,在显示初始页面加载的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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