Distinguish scripts-server side and client script in Web pages

Source: Internet
Author: User
General introduction of Dynamic Web development data will be mechanical to first speak HTML, and then have time to talk about JS, and then cut to the point of the Dynamic Web page section, and finally give some examples, such as message board, forums, even small e-commerce sites and so on. And the newer asp.net may even only start from WinForm, and then say WebForm ... This makes it more impossible for programmers to touch the underlying code and understand the overall architecture and workflow. I think the appearance of ASP.net is a bit like the birth of high-level language, the compiler of advanced language has implemented the process of automatically compiling the link advanced Language code into the assembly code, although the final code may not be so concise, but after all, the multiple optimization is also within the acceptable range. Today's asp.net intended to encapsulate all the client code, to implement the automatic generation from webui+codebehide to HTML, but for a variety of reasons it is still not enough to fully meet the needs of the developer (so to speak, it produces the "assembly code" is not satisfactory), Many basic features need to understand client script and make manual modifications to achieve it.
It is in this paradoxical phase of asp.net that we have more reason to acquire more knowledge from HTML, CSS to JScript, behavior, XML. Back to the point, this article will directly put the server-side script and client script in a piece to tell the comparison, this is rarely done, you can unlock some of the beginner's confusion, such as why the server-side script is not a pop-up dialog box, pop-up box, open a new window and so on. Let's take a look at the scope of the two, and then give an example of how to make it possible to interact with each other to achieve stronger functionality.

The figure for the early PHP4 layering, although from the current N-tier architecture to see the painting is not very clear, but still can understand. Two scripts are simple: As the name suggests, one runs on the server side and one runs on the client. And their task is very clear: server-side script only to generate Web page code (can include HTML, CSS, JS, etc.), it is usually said Asp/asp.net, PHP, JSP, etc., in the Dynamic Web page generally used "<%%>", "" > "and other symbols surrounded, in the multi-layer framework can also be beans,codebehide and so on. Client script is completely interpreted in the client browser, either in the "<script>", or in some events, or a single file, the view of the source code generally can be seen, the final browsing of the user is relatively open. It controls the user's interaction with the browser, and if the browser is viewed as an application, all of its actions are client-side script, which explains why there is always no server-end function that pops up the dialog box.
Because the script used by the ASP itself is exactly the same as the client script, both JScript (or JavaScript) and VBScript, it often makes beginners feel confused and confusing <script runat= "Server" > This sign. In fact, the above principle, the "<%%>" surrounded by the code must be server-side script, of course, and <script runat= "Server" > (this is not all marked is running on the server side of the), This code will not be found in the final HTML code after it has been interpreted by the Web server. There is also a point to understand is that either JS or VBS can be used to write any one end of the script, but generally more accustomed to use JS to write client script. As for the general use of VBS to write server-side scripts may be a habit, one is to differentiate.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.