Click here to Skip to main content
15,903,385 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
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?
Posted

1 solution

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[^]
 
Share this answer
 
Comments
Member77 28-May-13 9:05am    
if i put "EnableClientScript" property as false and then i have to use Page.IsValid property for server side side validation?
bbirajdar 28-May-13 9:15am    
Server side validation will still be done. But with Page.IsValid you can decide what has to be done if validation fails or succeeds
Member77 28-May-13 9:27am    
ok
Thanks.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900