Search Search

#1 worldwide
FREE Coding Lessons

since 1996
   THE BEST WAY to learn ASP & Asp.net!
Advertise Here!
click for details
Credits Host:
DiscountASP.net
Server Admin:
The "Team"
Contact Info.
Charles M. Carroll

my Blog
[prev. Lesson]  MS Online Documentation
     [next Lesson]  Response: Buffers, Redirect

Response Object

The response object is useful, feature rich, and subtle. We are going to focus on it's most fundamental capabilities -- the 20% you will use 80% of the time. The capabilities we think are vital include:

  • response.write
  • response.write alternate syntax <%= %> which allows ASP simply placed in HTML
  • response.end which effectively halts a script in it's tracks.
  • response.redirect which transfers control to another page

Here is a script utilizing response.write to send some information to the browser. It also uses dateadd, a built-in function documented at http://help.activeserverpages.com/iishelp/VBScript/htm/vbs90.htm.

   filename=/learn/test/response.asp

<Test Script Below>


<html><head>
<title>response.asp</title></head>
<body color="#FFFFFF">
<%
when=now()
tommorow=dateadd("d",1,when)
twoweekslater=dateadd("ww",2,when)
fourteenweekdayslater=dateadd("w",14,when)
monthlater=dateadd("m",1,when)

sixminuteslater=dateadd("n",6,when)
sixhourslater=dateadd("h",6,when)
fortysecslater=dateadd("s",40,when)

response.write "Now <b>" & when & "</b><br>"
response.write "tommorow <b>" & tommorow & "</b><br>"
response.write "2 weeks from Now <b>" & twoweekslater & "</b><br>"
response.write "fourteen working days from Now <b>" & fourteenweekdayslater & "</b><br>"
response.write "1 month from Now <b>" & monthlater & "</b><br>"
%>
six minutes from now <b> <%=sixminuteslater%> </b><br>
six hours from now <b> <%=sixhourslater%> </b><br>
fourty seconds later <b> <%=fortysecslater%> </b><br>
</body></html>

Here is a script utilizing response.end to prematurely end a page:

   filename=/learn/test/end.asp

<Test Script Below>


<html><head>
<title>end.asp</title></head>
<body color="#FFFFFF">
<%
when=now()
tommorow=dateadd("d",1,when)
twoweekslater=dateadd("w",2,when)
monthlater=dateadd("m",1,when)
sixminuteslater=dateadd("n",6,when)
sixhourslater=dateadd("h",6,when)

response.write "Now <b>" & when & "</b><br>"
response.write "1 month from Now <b>" & monthlater & "</b><br>"
response.end
response.write "2 weeks from Now <b>" & twoweekslater & "</b><br>"
%>
six minutes from now <b> <%=sixminuteslater%> </b><br>
six hours from now <b> <%=sixhourslater%> </b><br>
</body></html>
There are many worthy charities!!. But perhaps help starving children in Africa or South America AND help Charles too. a $5 tip buys him lunch at McDonalds, a $20 tip buys his kid Hitoshi a new computer game, a $39 tip buys his daughter Michiko a few nice outfits. See our donor list.