thevan
thevan

Reputation: 10354

When to use JavaScript in ASP.NET?

I am a beginner in ASP.Net. We have Validation Controls in ASP.Net. But I want to know, In which scenarios we need to use JavaScript?

Upvotes: 1

Views: 1627

Answers (3)

jon_darkstar
jon_darkstar

Reputation: 16768

When you want validation to happen on the client side. That is, validate before anything is sent to the server (ie - form submission) so its more responsive and doesn't waste server resource unnecessariy.

This can be done when a submit button is clicked but before the actual request is sent, when a certain input box loses focus, keypresses on a textbox to keep letters out of a numeric input, or pretty much on any event.

Upvotes: 1

Sudantha
Sudantha

Reputation: 16204

Specially in Validation approaches if you need to validate a email address in ASP.NET you need to send a server request and get the resonance

in JS you can validate in client side with out sending a server request

Upvotes: 1

Jimmy Chandra
Jimmy Chandra

Reputation: 6580

JavaScript will provide you with the ability to do client side validation which will allow you to save server roundtrip and makes your application less chatty, which is generally a good thing. I believe the validation controls in ASP.NET do have the ability to do client side validation as well (it will generate the necessary JavaScript and save you the work).

Upvotes: 2

Related Questions