When to use javascript instead of creating an aspx page?

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

+4
source share
8 answers

Javascript is a client technology that works only in a browser, while ASP.NET works on the server side. This allows you to achieve different and additional things.

With the classic server-side language, any user interaction that you want to respond to should normally be hosted over the Internet from a browser to your server. It is then processed by a server that responds with a new browser download page. This usually means that the response time for the user is slower, although you will have access to a much richer server programming environment.

With client-side language, everything is handled in the browser. This allows you to speed up user feedback, although due to the work in the much more limited programming environment that the browser provides, and without access to what your application may depend on, for example, on your database.

Of course, the lines get a little blurry when you make an AJAX request (usually this is a call written in Javascript that makes a request to the server, receives a response, and dynamically refreshes the page).

You mentioned that you are not using Javascript yet. Perhaps you would like to explore client input validation as a starting point? Thus, errors are caught and reported to the user immediately without the cost of a 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 to give the best experience to the user.

+7
source

In my experience, using Javascript / jQuery in .NET was intended to test the user interface and client side. If you are creating an application that does not require Javascript to meet your client requirements, then take advantage of what .NET has to offer. However, implementing Javascript is not that difficult, so feel free to use whatever you prefer for the benefit of the client. You can still write and use Javascript on an ASPX page.

+5
source

One of your considerations may be speed. Javascript on the web page will be launched in the browser of the site visitor. The code is executed on the server on which the page is hosted.

+3
source

from my experience, the main goal of using the html, css, javascript companion with asp.net when a client is needed is a web application that acts just like a win app

that you do not need to reset the page to the server and return again

+3
source

Points that you are missing

  • The code behind is not what ASP.NET does; you can make a web application with all c # code directly into aspx files.
  • If you choose ASP.NET and C # for your web application, all of your pages should be aspx, except in very specific and not very common situations.
  • You need to understand the difference between server-side scripts and client-side scripts. ASP.NET is a server-side scripting technology, and javascript is only client-side. Take a look .
  • You can create aspx pages that are as simple as you want - even without any corresponding server-side scripts - and that's all right.

Attempt to answer

You use the word must, therefore:

  • You should use aspx instead of javascript if you want to handle either side of the server.
  • You should use an html file with simple javascript, jquery and css if there is a specific request to do this, which would be very unusual. This may be a situation where a) the page should be as fast as possible b) . You don’t mind that everyone can see your full code, just select the viewing source in the browser c) there is no need for server-side processing d) You do not mind a small additional combination of technologies on the Internet. attachment.
+3
source

You use Javascript / JQuery to perform operations that do not require server-side processing, such as checking controls for a range or empty values, some fancy user interface elements. This is much faster than the code behind, because it does not send the server back, but you can use the server control of UpdatePanel aspx for a partial message and not reload the page.

As a web developer, you should always use a combination of server-side processing and client-side processing. The working logic and application processes on the client side allow browser-based applications to appear more responsive and have more β€œaffection” for them.

+2
source

If you are looking for highly customizable and high-performance pages, I would go with html + javascript + css and make calls to some web service. This way you are not limited to asp.net controls. In addition, there are many caveats with standard web form forms that can lead to page performance and overhead problems - ViewState is one of them. You can also create your own asp.net controls, but there is a specific learning curve.

It really comes down to personal preference (there is nothing in one that you cannot do in another): Fundamentals versus abstraction. For me, javascript always felt a little cumbersome when used in conjunction with webforms, however, with mvc it is much more natural, as it would be with the standard html + javascript + css page.

+2
source

If you want to create static pages, you can use html + css + javascript instead of aspx. If you need more dynamic things, you should use aspx with cs.

For more information, go to http://www.w3schools.com/aspnet/aspnet_pages.asp

-1
source

Source: https://habr.com/ru/post/1401369/


All Articles