Lesson 1: create a simple ASP page

Source: Internet
Author: User

Lesson 1: create a simple ASP page

The best way to learn about ASP pages is to write your own ASP pages by hand. Creating an ASP page is simple, just use the text editor to insert the script command into the HTML page. Save the main page with. ASP as the extension name of the file, and the ASP Server knows how to handle the script in it. To check the results of the script, you only need to use the HTTP protocol in the web browser to check the page. Also, press http: // localhost/IISHelp/IIS/htm/tutorial/filename. asp. In this lesson, you will create the "Hello world! "Script, the method is to rewrite the HTML and ASP script from the tutorial to the text editor. After saving the file in the file editor, you can use the browser to check the output result of the script.

The following HTML creates a simple master page with only the text "Hello worl" displayed in a large text
D! ":
<HTML> 〉
<Body> 〉
<Font size = 7> 〉
Hello world! <Br> 〉

</Font> 〉

</Body> 〉

</Html> 〉

if you want to repeat the text several times, and the size of each word increases. One method is to repeat the font mark and HTML text, and give different characters for each repeat. When the browser opens this HTML page, this line of text is displayed several times.

Another method is to use ASP to generate the same content, which is more flexible than the traditional method. Create and save the master page enable Text Editor (for example, "Notebook") or word processing software (such as Microsoft? Word ). Adjust the editor window and browser window on the screen so that you can see them at the same time.
Repeat the following HTML Tag and paste it to the opening header of the file:
<%@ Language = "VBScript" %> 〉
<HTML> 〉
<Body> 〉
Note that the first mark is a special ASP mark, which is used to set your recognition script to VBScript. Add this note to the first line of your. asp file.
Save the file as hello. asp to the tutorial directory (C: \ win NT \ HELP \ IIS \ HTM \ tutorial) of the localhost web server. If you use the word processing software (including the "Writing Board"), please ensure that the file is saved in plain text. ASP pages must be suffixed with. asp for normal work.
If so, another user has already created hello. after learning this part of the course, you can overwrite the old hello. ASP file.
After the "body" mark, start a new row and rename and paste the following script:

<% For I = 3 to 7%> 〉
The script command is enclosed by the "%" and "%" characters. These two symbols are usually called start and end characters ). The characters in the start and end characters are used as scripts. Any text after the start and end characters on the right side will be displayed as HTML text in the browser. The above script starts a VBScript cycle, which is used to control the number of times that show "Hello World. For the first round of the cycle, the variable (I) of the calculator is set to 3. The second round of the cycle. The calculator is set to 4. The cycle is continued until the value of the calculator is greater than 7.
Press the next return key, then re-create and paste the following columns:
<Font size = <% = I %> 〉〉
In each cycle, the font size is set to the value before the I value of the calculator. For this reason, when the text is displayed for the first time, the text size is 3. The second time, the font size is 4. The last time, the font size is 7. Note: The script command can be included in the HTML Tag.
Press the next return key, then re-create and paste the following columns:
Hello world! <Br> 〉
</Font> 〉
<% Next %> 〉
</Body> 〉
</Html> 〉
The next life cycle of VBScript is repeat until the value of the number generator is greater than 7.
The complete hello. asp file must contain the following text:
<%@ Language = "VBScript" %> 〉
<HTML> 〉
<Body> 〉
<% For I = 3 to 7%> 〉
<Font size = <% = I %> 〉〉
Hello world! <Br> 〉
</Font> 〉
<% Next %> 〉
</Body> 〉
</Html> 〉
Save the file. Note that the file name must be. asp.
In some text series, When you select the "plain text" format in the "save" text box, the Editor automatically changes the suffix of the file name. TXT. If this happens, you need to change the. txt suffix to. asp, and then click Save.
Return to the source editor. When an HTML page is opened by the text editor, the browser may not be able to access it again.
To check the result of your work, export your browser to http: // localhost/IISHelp/IIS/htm/tutorial/Hello. asp. (If you want to return back to this tutorial, you only need to click the "Previous Page" or "back" button in the browser. )
You can see that a main page shows "Hello World" for five times, and the size of each word increases.
Congratulations! You have completed your first ASP master page. As you have learned
The process on the ASP main page is shown in this example. You can use any text editor to Create HTML content and write ASP scripts in

<%

And

%> 〉

And save the file with the. asp suffix. To test the ASP page and check the result,
You only need to find the main page in the browser (if the main page has been opened, you only need to click New ).

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.