I have multiple usercontrols each displayed by pressing a button and then change the apperance to a new user control and so on. I have to check that almost every field in this user controls have a value entered, and then indicate (e.g. with a red star) those textboxes that does'nt have a value entered.
How should I do this in the best way, client side or server side with some validator? I have in mind that when using a server side validator, it may dissapear when making a postback. But I'm not sure, and I assume there is a way to come around this problem?
What do you all say? Client side or server side validation in my case, and why?
Thanks in advance!
// Carl
![]() |
0 |
![]() |
Both.
You should always validate client side where possible for performance reasons.
You should always validate server side for performance and security reasons.
Regards
Dave
![]() |
0 |
![]() |
Ok! But where should I "mark" the field who doesn't have a value? Client or server side? And I want it to persist postbacks.
But why using both validations? Can you explain that further?
Should I use javascript for client side validation and RequiredFieldValidator for server side validation? Or do you have some other suggestion?
![]() |
0 |
![]() |
If you are just checking for blank values I would suggest using client side validation, however; if you need to check against a value in a database, server side is the most secure.
I believe the RequiredFieldValidator automatically generates javascript code if you are just checking for blank values.
![]() |
0 |
![]() |
The Validator web controls provide both client and server side validation.
1. Add the RequiredFieldValidator to each control in the location you want the "mark". Set up the mark in the ErrorMessage property.
2. Client-side validation is automatic. Server side validation requires one additional step. In your Click event method, test Page.IsValid is true before saving.
--- Peter Blum
Creator of Peter's Data Entry Suite (formerly Professional Validation And More and Peter's Date Package) and Peter's Polling Package
www.PeterBlum.com
![]() |
0 |
![]() |
PLBlum wrote:
The Validator web controls provide both client and server side validation.
1. Add the RequiredFieldValidator to each control in the location you want the "mark". Set up the mark in the ErrorMessage property.
2. Client-side validation is automatic. Server side validation requires one additional step. In your Click event method, test Page.IsValid is true before saving.
In regards to #2, Not true - Server side validation causes validation as long as the submit button's CausesValidation property is set to true. If the page does not validate, it sends you back and does not run the Button_Click event.
THIS DOLL IS VERY GOOD FOR YOU AND VERY GOOD FOR EVERYBODY SO I'M GLAD YOU'RE ENJOYING IT HERE IN THIS BEAUTIFUL MOOD HOUSE. I WISH YOU WELL.
![]() |
0 |
![]() |
unborracho wrote:
In regards to #2, Not true - Server side validation causes validation as long as the submit button's CausesValidation property is set to true. If the page does not validate, it sends you back and does not run the Button_Click event.
I'm sorry but we disagree. The Button's OnClick event calls Page.Validate() automatically when CausesValidation is true. It *always* calls your Click event handler. You are responsible for testing Page.IsValid is true in that method. Its one of those things that users always miss and discover their pages aren't working correctly on non-IE browsers (which depend on server side code). Here is the .net documentation on it: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpref/html/frlrfsystemwebuipageclassisvalidtopic.asp
Notice: "You should check this property only after you have called the Page.Validate method, or set the CausesValidation property to true in the OnServerClick handler for an ASP.NET server control that initiates form processing."
--- Peter Blum
Creator of Peter's Data Entry Suite (formerly Professional Validation And More and Peter's Date Package) and Peter's Polling Package
www.PeterBlum.com
![]() |
0 |
![]() |