开发者

What is the use of JavaScript?

Why do I need script on an as开发者_运维问答px page?


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.


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


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


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.


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


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.)

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜