JavaScript ASP Tutorial Lesson Two--Escape character _asp Basics

Source: Internet
Author: User
Tags html page
Not a digression:
The "escape character" we're going to talk about in the second lesson doesn't seem to be related to our course. That is not the case. The escape character is in the

An integral part of JavaScript used in ASP. And the second lesson is exactly the escape character. There are no escape characters, so you

Writing an efficient ASP script can be a lot of trouble.
Sorry, let's get down to business:
The following is the ASP script for lesson two.

Also remember in the first lesson of Liezi, how we wrote an HTML output all in the same line of code. The escape character allows us to increase

The newline symbol.
Here is the code for our top example in the Client HTML output page:

Line feed:
I hit the next line of ASP script again. Pay attention to the "\ R" that you added at the end.
Response.Write ("\ "Hello world\"
\ r ")
"\ r" is a special tag for line breaks. This is the symbol that makes my output on the HTML page broken into several lines. This should be in large

It is very important to use a program or a large page. I once said, once again I repeat. Believe me: If you don't write

The head and tail of things are not clear, you will not find out what you have in the client output of what bugs.
Reference character:
There is one thing you must pay attention to. Think about how I added "\" behind some quotes. If I remove "\", it will

What happened? Let's try the following line of script.

We will probably get an error code listed below:

does not have an escape character:
What if I don't like the escape character? Do I have to use them?
You will be unable to move without them. Look at the following script:
Response.Write (" ' Hello World '
")
You can alternately use double quotes and single quotes. In my opinion, this is only a stupid way, but it is really a useful way. Even without that, at least from the perspective of HTML aesthetics, we should use the escape character.
Checklist:
One of the things that makes us use the escape character is not very important because he can allow us to output some special characters.
Most Important:
The most important reason for using escape characters (at least for some complex applications) is for the connection of the database. (We'll have a separate course to tell you about the database later.) ) Compare the following two connection strings.
var connection= "Provider=Microsoft.Jet.OLEDB.4.0; Data source= "+ Server.MapPath (" \\TopLevelVirtualFolder ") +" \\DATABASE\\MYDATABASE.MDB; "

Dim Connection;
Connection= "Provider=Microsoft.Jet.OLEDB.4.0; Data source= "& Server.MapPath (" \toplevelvirtualfolder ") &" \database\mydatabase.mdb; "

Next Lesson:
We have to have a gadget when we write our ASP in JavaScript, and we'll talk about it in the next lesson.



The original and example address of this section: http://aspjavascript.com/lesson02.asp
Original author: James Clark translation: Huahua reprint please specify
Related Article

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.