logo
g Text Version
Auto
Beauty & Self
Books & Music
Career
Computers
Education
Family
Food & Wine
Health & Fitness
Hobbies & Crafts
Home & Garden
Money
News & Politics
Relationships
Religion & Spirituality
Society & Culture
Sports
Travel & Leisure
TV & Movies

dailyclick
Bored? Games!
Postcards
Astrology
Take a Quiz
Rate My Photo

new
English Garden
Costuming
Charity
Women's Fashion
Pop Music


dailyclick
All times in EST

Full Schedule
g
g ASP Site
Editor Wanted
BellaOnline's ASP Editor

g

Using the RESPONSE Object
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.

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.

<form name="form" method="post" action="mypage.asp">
<input type="text" name="fullname" value="<%=name%>">
</form>

will produce an input box with "Linawaty" in it.


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
%>

<form name="form" method="post" action="page1.asp">
<input type="submit" name="button" value="page2">
<input type="submit" name="button" value="page3">
</form>

Then we create page2.html and page3.html so that each contains only some text to let you identify them.
Page2.html :

<html>
<head>
<title>Page 2</title>
</head>
<body>
This is Page 2.
</body>
</html>

Page3.html :

<html>
<head>
<title>Page 3</title>
</head>
<body>
This is Page 3.
</body>
</html>


3. Response.End
This method is used mainly for debugging. It will stop the ASP script at the exact point where it is inserted.

Example:

<%
response.write "First line"
response.end
response.write ", Second line"
%>

will produce a "First line" output on your browser instead of "First Line, Second Line".

This site needs an editor - click to learn more!

RSS | Related Articles | Previous Features | Site Map


Content copyright © 2008 by Linawaty. All rights reserved.
This content was written by Linawaty. If you wish to use this content in any manner, you need written permission. Contact BellaOnline Administration for details.

Digg! g delicious Save to Del.icio.us

g


For FREE email updates, subscribe to the ASP Newsletter


Past Issues


print
Printer Friendly
bookmark
Bookmark
tell friend
Tell a Friend
forum
Forum
email
Email Editor

g features
Best uses for RSS

RSS and its future.

Force Download Dialog box with ASP

Archives | Site Map

forum
Forum
email
Contact

Past Issues
memberscenter


vote
Driving Amount
Much more
Slightly more
Slightly less
Much less

g


| About BellaOnline | Privacy Policy | Advertising | Become an Editor |
Website copyright © 2008 Minerva WebWorks LLC. All rights reserved.


BellaOnline Editor