views:

102

answers:

7

Why do I need script on an aspx page?

+4  A: 

Javascript will allow you to perfrorm client side coding, so to avoid having to post back to the server.

From Using JavaScript Along with ASP.NET

Working logic and application processes on the client-side allows browser based applications to seem more responsive and to have more "snappiness" to them.

astander
+1  A: 

For client scripting, i.e. validation. There are many scenarios where you need to execute certain logic on the browser's end.

Kerido
+1  A: 

It helps in doing things on the client side, which essentially means you can :

  • reduce burden on your server by doing less postbacks.
  • do a round of validations on the client side itself if they are non critical.
  • Do some fancy stuff like animations etc with out contacting the server

There are a lot more implications/uses of using JavaScript.

For knowing more, remember google is your friend!

Thanks

Mahesh Velaga
+1  A: 

Javascript runs on the client side. So if you want anything to happen or change without refreshing the whole page you use javascript.

Mattias Jakobsson
+1  A: 

There are a lot of things the server can't really do that well. For example if you want to manipulate the page. You could post the whole thing back to the server with some sort of action and get the server to give you a new page. Or you could just use javascript to change it for you and avoid the trip to the server. It is faster for the client and takes the load off of your server.

uriDium
A: 

Theres not much use for it at all really.

foosadi
Since when is this true :) ?
anthares
What world are you living in? Javascript is a very important part of web development today.
Mattias Jakobsson
Wow...didnt knew this, and I had been slogging with it from last 8 years....thanks for brining me up-to-date
Bhaskar
Its a little bit of variety, no point repeating a what 10 other people have said! Nice tactical voting Mattias Jakobsson
foosadi
Wow, and I thought I was being a bit of a troll having a joke. The true trolls like Bhaskar then crawl out!
foosadi
+1  A: 

I'm not sure if you mean why ASP.NET pages requires Javascript, or if you mean additional scripts on the page.

ASP.NET uses Javascript for several types of postbacks. If you for example have a LinkButton, a script is making a postback instead of the default action of the link.

You can use additional scripts on the page for visual effects and to verify data before doing a postback to prevent unneccessary postbacks. (Of course you should also verify the data on the server side to protect against malicious actions.)

Guffa