ASP Getting Started tutorials common methods for-response objects

Source: Internet
Author: User
Tags current time html tags response write

One, write method

The Write method of the Response object can directly output information to the HTML file that is sent to the client browser. That is, reponse the eel with 腤 rite method to output information from the WEB server to the browser. The syntax format is as follows:

Responser.Write Variant

Note: Variant parameter values can contain any valid HTML tags, but cannot include character combination%> If you want to include symbols in the information that the browser displays:%>, you must write:%> to avoid being treated as an end tag for ASP code. When writing scripts using Vbsxript, a string constant cannot be used as a parameter because the static string constants of VBScript cannot be longer than 1022 bytes, so if you want to use the Write method to output content that is longer than 1022 characters long, Instead, you should use other forms, such as variables, to refer to the content. At the time of writing, Response.Write can be substituted with "=". For example, <% Response.Write y%> can also be written as <% = y%>. The Response.Write method is similar to the Document.Write method in VBScript, except that the Response object is an ASP built-in object whose function is to output data from the Web server to the client browser Document is a browser object whose Write method functions to output data directly to the browser.

Example one: This example uses the response Write method to output a complete HTML file to the client browser. The code is as follows:

<% @ Language="vbscript" %>
<%
Response.Write "<HTML>"
Response.Write "<HEAD>"
Response.Write "<TITLE>Response对象Write方法的应用实例</TITLE>"
Response.Write "</HEAD>"
Response.Write "<BODY>"
Response.Write "<CENTER>"
Response.Write "<font color='red' size='6' face='华文彩云'>**留意你的宝石**</font>"
Response.Write "</CENTER>"
Response.Write "Response.Write "<font color='#cc9999' size='5'>"
Response.Write"&nbsp;&nbsp;&nbsp;&nbsp;上帝是公平的,无论对谁,都赐予一个盛着宝物的锦囊,那里面装有时间、健康、梦幻、激情、才干等足以让我们开创美好生活的宝石,有的人感激于上帝的馈赠,用这些宝石来换取更多的宝石,而有的人却很轻易地扔掉了这些宝石;最终弄得两手空空,只留下一串羡慕、追悔、抱怨……<br>"
Response.Write"别随手扔掉你的宝石。从现在开始,弯下腰来,攥紧拳头,播撒汗水,去寻觅、去思索、去创造,用上帝赐予你的锦囊去获取生命中更多的瑰宝!"
Response.Write "</font>"
Response.Write "</BODY>"
Response.Write "</HTML>"
%>

Second, redirect Web site

The response object's Redirect method enables the browser to move from the current Web page to another page. The syntax format is as follows:

Response.Redirect 路径

Annotations:

"Path" refers to the URL of a new page; Because Response.Redirect is telling the browser to open a new page, Response.Redirect must be placed before the data is exported to the browser, in other words, Response.Redirect In front of the <HTML> tag of the program, to call it after the

Example two: This example through the system clock to determine whether the current time is greater than or equal to 5 o'clock in the morning, and less than or equal to 19 points, if it is redirected to the 4-2c1.htm page, otherwise redirected to the 4-2c2.htm page. The code is as follows:

<% @ Language=VBScript %>
<%Response.Buffer=True %>
<body>
<%
myTime=time()
if myTime>=#5:00:00# and mytime<=#19:00:00# then
PageName="4-2c1.htm"
else
PageName="4-2c2.htm"
end if
Response.Redirect PageName
%>
</body>

The 4-2c1.htm page code is as follows:

<body>
<font color="red" size="7" face="华文彩云" align="center"><b> 欢迎光临本网站!</b></font>
</body>

The 4-2c2.htm page code is as follows:

<body>
<font color="green" size="7" face="华文彩云" align="center"><b> 本网站每天的17点到凌晨5点是休站时间。谢谢合作!</b></font>
</body>
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.