Javascript asp tutorial Lesson 2-escape characters

Source: Internet
Author: User

It is not a digress:
The "Escape Character" we will talk about in the second lesson seems to have nothing to do with our course. This is not the case. The escape character is in

Asp uses a complete Part of javascript. The second lesson is about escape characters. There are no escape characters.

Writing efficient asp scripts will encounter many difficulties.
Sorry, let's go to the topic below:
The following is the asp script for Lesson 2.

I still don't remember how we wrote an html code with the same line of output in the first lesson. Escape characters allow us to add

Line feed symbol.
Below is the code of the above example html output page on the client:

Line Break:
I typed an asp script again below. Note that "\ r" is added at the end ".
Response. Write ("\" Hello World \"
\ R ")
"\ R" is a special line break Mark. This symbol divides the output on the html page into several lines. This is suitable for large applications.

Applications or large pages are very important. I once said that I repeat it once again. Believe me: If you connect to what you write

If the header and tail of the things are unclear, you will not find any bugs in the things you output on the client.
Quote:
You must pay attention to the other things. Think about how I added "\" behind some quotes. If I remove "\",

What happens? Let's try the following script.

We may get an error code listed below:

No escape characters:
What should I do if I do not like escape characters? Do I have to use them?
Without them, you will be unable to do anything. Take a look at the following script:
Response. Write ("'Hello world'
")
You can use double quotation marks and single quotation marks. In my opinion, this is just a stupid method, but it is indeed a useful method. Even if there is no such argument, at least from the perspective of html aesthetics, we should still use escape characters.
List:
It is not very important that we use escape characters because they 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 database connection. (A separate course will be provided later to describe the database .) Compare the two connection strings in the upper-right corner.
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 must also have a small tool when writing asp in javascript. We will talk about it in the next lesson.

Original article and example address: http://aspjavascript.com/lesson02.asp
Author: James Clark

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.