我们可以使用服务器验证器控件将Page.IsValid属性用作服务器端验证吗? [英] Can we use Page.IsValid property as server side validation using Server Validator Controls?

查看:109
本文介绍了我们可以使用服务器验证器控件将Page.IsValid属性用作服务器端验证吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用服务器端控件,如RequiredField Validator,RegularExpression Validator等。
我的应用程序中的
并且从未在代码隐藏文件中使用任何验证代码

(.cs文件)。现在要求我必须在我的应用程序中同时使用客户端和服务器端验证。如果我为每个页面中的每个控件编写验证代码,则需要花费大量编码和时间。

因此,我搜索并发现我们也可以使用Validators进行服务器端验证。 br />
我们可以通过检查每页上的Page.IsValid属性来使用它。

但我对使用Page.IsValid Property有疑问。



所以,请帮我解决使用Page.IsValid属性的疑虑。它是否可以作为服务器端验证?

I am using Server Side Controls like RequiredField Validator, RegularExpression Validator etc.
in my application and have never used any validation code in code behind file
(.cs file). Now there is a requirement that i have to use both client side as well as server side validation in my application. If i write validation code for each controls in each and every page, it will take so much coding and time.
So, i searched and find out that we can use Validators for server side validation also.
We can use it by checking Page.IsValid property on every page.
But i have a doubt regarding use of Page.IsValid Property.

So, please help me for clearing doubts about using Page.IsValid property. Will it work as server side validation?

推荐答案

所有验证控件都执行各自的验证两个客户端

和服务器端。验证首先在客户端完成,以防止在数据被证明违反验证

规则时浪费了b $ b浪费在服务器上。假设数据是好的(或似乎是),则在服务器上再次验证

以捕获客户端的任何欺骗尝试。



验证控件具有EnableClientScript属性(默认为

true),以指示客户端验证是否应该实际发生

(这是大概是在客户可能有脚本的情况下

关闭)。即使此设置为false,服务器端验证仍将发生




了解ASP.NET验证技术 [ ^ ]
All the validation controls perform their respective validations BOTH client
and server side. The validation is first done client side to prevent a
wastefull trip to the server when the data is know to violate the validation
rules. Assuming the data is good (or seems to be), the validation is again
performed on the server to catch any spoofing attempts by the client.

Validation controls have an "EnableClientScript" property (which defaults to
true) to indicate if the client side validation should, in fact, take place
(this is presumably for situations when the client might have scripting
turned off). Even if this setting is false, the server side validation will
still occur.

Understanding ASP.NET Validation Techniques[^]


这篇关于我们可以使用服务器验证器控件将Page.IsValid属性用作服务器端验证吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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