Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

When to use javascript instead of creating an aspx page?

I am new at C#.Net and i have one question that i couldn't manage to find on the internet. When should i use a classic combination of html + javascript + css instead of using an aspx page with a code behind? As i experienced since i started .net , i found that aspx pages and code behind is a huge ease for developers. I didnt need any piece of javascript code since i started. There must be something wrong. I think i am missing a point. Can you answer my question and tell me some examples that i must use html+javascript+css instead of aspx + aspx.cs or vice versa?? Have a nice day.

like image 840
Mert Karatas Avatar asked Mar 14 '12 12:03

Mert Karatas


People also ask

Where do I put JavaScript in ASPX page?

Just add the script tags in the master page or content page and the javascripts can be included in them. If you want to add a JavaScript file to them, you can use src attribute in the script tag. Lastly, please pick any basic book, read first and then start coding! Please Sign up or sign in to vote.

Do .NET developers use JavaScript?

Moreover, JavaScript can be used with HTML5 for game development, mobile applications and even Windows Store apps. As a . NET developer, you can't ignore the capabilities of JavaScript, nor its spread in the marketplace.

What is the difference between ASPX and HTML?

HTML Page : A Web page with user interface and content static information that does not go through any server-side processing. ASPX Page : A Web page with user interface and dynamic content information that is coming from server-side.

Can we write C# code in ASPX page?

yes, you can write C# in aspx page. Yes, if you want write c# code in same aspx file. First time you add new item > web form > check/uncheck place code in separate file.


1 Answers

Javascript is a client side technology, running only in the browser, whereas ASP.NET runs on the server side. These allow you to achieve different and complementary things.

With a classic server side language, any user interaction that you want to respond to must typically be posted across the internet from the browser to your server. It is then processed by the server, which responds with a new page for the browser to load. This generally means that the response time for the user is slower, though you will have access to a much richer programming environment on the server.

With a client side language, everything is processed on the browser. This allows for faster feedback to the user, though at the expense of working within the much more restricted programming environment that the browser gives you, and with no access to stuff your application may depend on, such as your database.

Of course, the lines are blurred somewhat when you make an AJAX request (usually a call written in Javascript that makes a request to the server, receives the response, and updates the page dynamically).

You mention that you have not used any Javascript so far. Perhaps as a starting point you'd like to investigate validating user input on the client side? This way, errors are caught and reported to the user immediately without the cost of the round trip to the server. http://www.tizag.com/javascriptT/javascriptform.php

Both client side and server side technologies can be powerful and useful. Use a combination of them both to give the best experience for the user.

like image 198
Mike Chamberlain Avatar answered Oct 05 '22 23:10

Mike Chamberlain