2

My question is having a really deadlock situation over validation purpose.

I can do validation with two things in ASP.net

  1. Using validation controls
  2. Using jQuery

Now there are several situations:

  1. If I use jQuery I can't use server side page.isvalid method to perform validation from the server side.

  2. If I use the validation controls The page which actually loads the validation controls. It makes the page bulky. So I want to avoid that part too. I don't want my client with lower bandwidth to load the page very slow. Because of those validation control generating viewstates and custom validation JavaScripts.

  3. If in browser the JavaScript debugging is turned off or the JavaScript execution is turned off . Neither jQuery nor validation controls on client side would occur. So in that case the only option I have is to use the page.isvalid method to validate the form from server side .

Now is it possible to consider all the three cases and perform a server side validation because JavaScript validation is vulnerable I really don't want to rely on it. But at the same time I see server side controls they are really bulky so without sacrificing my bandwidth (which definitely I won't want rather I would tend to use JavaScript validation). And also if in case my jQuery is failed due to JavaScript execution has turned off. How to perform server side validation without any kind of use of validation controls?

1
  • 2
    I am not sure I follow. Server-side validation should be totally independent from client-side validation. At any rate, never trust client input - always validate on the server side. Commented Sep 9, 2011 at 5:04

2 Answers 2

1

I think you overestimate the cost of using validation controls. It does add a little overhead to the page, but not as much as you seem to think. If you would like to use Page.IsValid, I would suggest using the validation controls. I've never known anyone to stay away from them for performance reasons.

Sign up to request clarification or add additional context in comments.

1 Comment

yes i do agree to the point that client side validations aint trustable... put still if there are 50 input controls . i have to put 50 validation controls for them... pardon me if i am wrong cause i m pretty new to this .. so doesnt tht add up to the viewstate of the page and increase the network latency ? i m jus mentioning my point. and are there any other way i can provide a server side validation apart from that page.isvalid + validation controls ?
1

+1 to both comments posted up to now but I would add that even though validation on the server side should always be performed, client-side validation is good because it provides immediate feedback to the user as opposed to posting back the entire page and wait for a couple of seconds to comeback with a list of errors. In Mobile development, for example, client-side validation is important because network latencies are typically bigger and you want to guarantee, as much as you can, that the input being submitted will pass validation on the server side in one shot.

In conclusion, client-side validation should never be trusted but should always be performed.

As a matter of taste, I would prefer to perform validation using JQuery than any of the asp.net validation controls.

1 Comment

@lcarus jquery is a good option but i want to balance both server side + client site.. but as i have mentioned in the comment above that server side validations are only done through page.Isvalid + validation controls . is there any other specific way i can do that ? apart from validation controls ?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.