Guest Author - Linawaty
So what is this response object for? Response object is used to send output to the user from the server. There are many methods assigned to it.
Some of them that are used mostly are :
1. Response.Write "string"
If you're an ASP programmer, I believe you are very familiar with this one. If you're not then you will be, as soon as you start learning ASP.
The first thing you learn in every programming language is to display some text on screen (on this context, browser), isn't it? You use this method to do it.
<% response.write "Hello World" %>
will produce a "Hello World" output on your browser.
You can also combine some string and predefined variable using "&"
myVar = "Linawaty"
response.write "Hello.. My name is " & myVar & " (^-^)/"
will produce a "Hello.. My name is Linawaty (^-^)/" output on your browser.
If you want to display some text or variable in the middle of lines of HTML, you can use shortcut <%="string"%>
It is practically the same as <% response.write "string" %>, just a little bit shorter and it doesn't allow anymore coding.
<% name = "Linawaty" %>
Assume you have predefined variable called "name" and you want to display it on the input box.
<form name="form" method="post" action="mypage.asp">
<input type="text" name="fullname" value="<%=name%>">
will produce an input box with "Linawaty" in it.
2. Response.Redirect "url"
We will create an ASP page that has a form with two buttons (say [page 2] and [page 3] buttons). Depends on which button you click, the script will redirect you to predefined page ([page 2] button to page2.html page and [page 3] button to page3.html page).
First we create a form with two buttons at "page1.asp"
if request.form("button")="page2" then
elseif request.form("button")="page3" then
<form name="form" method="post" action="page1.asp">
<input type="submit" name="button" value="page2">
<input type="submit" name="button" value="page3">
Then we create page2.html and page3.html so that each contains only some text to let you identify them.
This is Page 2.
This is Page 3.
This method is used mainly for debugging. It will stop the ASP script at the exact point where it is inserted.
response.write "First line"
response.write ", Second line"
will produce a "First line" output on your browser instead of "First Line, Second Line".