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.
Example:
<% response.write "Hello World" %>
will produce a "Hello World" output on your browser.
You can also combine some string and predefined variable using "&"
Example:
<%
Dim myVar
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.
Example:
<% name = "Linawaty" %>
Assume you have predefined variable called "name" and you want to display it on the input box.
2. Response.Redirect "url"
This is another method of RESPONSE that you would find useful soon. We use this method to redirect to another page. It is the same as javascript's window.location="url"
Example:
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"
page1.asp :
<%
if request.form("button")="page2" then
response.redirect "page2.html"
elseif request.form("button")="page3" then
response.redirect "page3.html"
end if
%>