ASP double quotes, single quotes, and numbers

Source: Internet
Author: User

Many ASP users may lose their way in double quotation marks, single quotation marks, and ampersand. The most important thing is not understanding the meaning of the three types of symbols. Of course, they cannot be well understood. The following are my views on the three types of symbols. If the technology is not refined, it is inevitable that there will be negligence. I would like to ask for more comments.

1, double quotation marks ""

ASP in double quotes can be any character, string, and HTML code.
For example

<% Response. write ("cnbruce here") %> <% Response. write ("<B> cnbruce here </B>") %>

The page effects are: the default text and bold text "cnbruce here"

Next, let's think about it. What if I want to add a color to the output page text?

1. The general text color is as follows: <font color = "# 0000ff"> cnbruce </font>

2. response. write is written as follows: response. write ("input displayed content ")

3. If you want to put the above hyperlink code in response. write, have you found that the double quotation marks in the write method and the double quotation marks in the color form a nested effect,
InevitableResponse. write ("<font color =" # 0000ff "> cnbruce </font> ")

4. the debugging result is not optimistic, because the color quotation marks match the write quotation marks and the content is<Font color =The quotation marks of the same color match the quotation marks of the write statement. The content is:> Cnbruce </font>. The final result is: # 0000ff in the middle is lonely.

5, so to make the result correct, you can put # 0000ff as a string in double quotation marks, and then the string and the front string<Font color =And the following string> Cnbruce </font>The intermediate connection uses& Amp; #

The final result is as follows:

<%
Response. write ("<font color =" & "# 0000ff" & "> cnbruce </font> ")
%>

2, single quotes''

Just like learning Chinese lessons, you can use single quotes to enclose the quotation marks in double quotes.

Then the preceding statementResponse. write ("<font color =" # 0000ff "> cnbruce </font> ")In # 0000ff, you can change its double quotation marks into single quotation marks:
Response. write ("<font color = '# 0000ff'> cnbruce </font> ")In this way, the execution is also correct.

3. Connection characters & numbers

In ASP, the Ampersand (&) is used for connection, including string-string, string-variable, variable-variable, and other hybrid connections.

For example:

<%
Mycolor = "# 0000ff"
Response. write ("<font color = '" & mycolor & "'>" & "cnbruce" & "</font> ")
%>

Note that the double quotation marks are used in the single quotation marks of color ~! You may be confused.

1. Now I have defined a variable mycolor. According to the principle, the variable is placed in response. double quotation marks are not required in write, because double quotation marks are used to indicate strings rather than variables.

2, so response. write can directly write response. write (mycolor)

3, but now. Our variables must be placed in double quotation marks (for example, the above program is placed in a single reference). How should we write the specific response. write?

4. Key Syntax: add the variables in ASP to the left or right"&Including, you can put it in the quotation marks of response. write. The effect is:Response. write ("" & mycolor &"")

5. Analyze response. write ("" & mycolor & ""). In fact, the first empty string connects to the mycolor variable and then connects to the next string.

6. Therefore, I should understand the entire ASP example above.

Continue to strengthen and deepen

<%
Mycolor = "# 0000ff"
Response. write ("<font color = '" & mycolor & "'>" & mycolor & "</font> ")
%>

This contains strings, variables, and variables used in quotation marks. I believe you can understand it.

Finally, you can use HTML and ASP in combination.

<% Mycolor = "# 0000ff" %>
<Font color = <% = mycolor %> </td>

This is not difficult and easy to understand :)

Well, that's all I thought.

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.