iTech College - Internet Technology, Online Education, E-Learning, Technician Training, Tech Tutorials, Distance Education, Virtual Learning ASP Course: Response and Request - www.itechcollege.com ASP Course: Response and Request - www.itechcollege.com
Online Degrees Scholarships & Fellowships Internships Student Financial Aid Study Abroad Itech Bookstore
Free Courses
HTML
JavaScript
CSS
ASP
PHP
JSP
ASP.NET
SQL
AJAX
FTP
XML
Career Center
Job List
Web Jobs
Student Jobs
Computer Jobs
Engineer Jobs
Developer Jobs
Job Search
Resume Writing
Job Interview
Salary Info


itech > courses > ASP > Response and Request

Response and Request

To display any content to web browser, you can use "Response.Write". The syntax is:

<%
Response.Write "This is my first ASP page." 
%>

"Response.Write" is like all other ASP scripts, not case sensitive. "Response.Write" is the same as "response.write". There is another method to do the same work using "<%=" and "%>":

<%="This is my first ASP page."%>

The output is the same:

This is my first ASP page.

Please notice that, to display a string, we must use double quotes.

To understand Request, let's create two ASP pages:

first.asp:

<html> 
<body> 
<a href="second.asp?user=John">Send Query String</a>
<form action="second.asp" method="post">
<input type="text" name="user">
<input type="submit" value="Send Query String">
</form>
</body> 
</html>

second.asp:

<html>

<body>
Hi <%response.write request("user")%>
</body>
</html>

Save the two pages in the same folder and open first.asp on web browser. Click the link "Send Query String", you will see second.asp come out and show the value "John":

Hi John

Back to first.asp. If you enter a value "Mike" in the text box, and click the button "Send Query String", you will see the value "Mike" displayed in second.asp:

Hi Mike

To retrieve the query string, we use Request. The syntax is:

request("<query string name>")

For example:

request("user")

To display this to a web page, we must use "Response.write" or "<%=%>":

<%response.write request("user")%>
<%=request("user")%>

To send a query string out, we should notice three points:

  • Where do you want the query string sent to;
  • What is the name of the query string;
  • What is the value of the query string.

You can use a link or a form to send a query string out. In the above sample, we point the query string to a destination page "second.asp", give the query string a name "user" and a value "John".

<a href="second.asp?user=John">Send Query String</a>  

Please notice that the express "second.asp?user=John" means: send query string named "user" and it's value "John" to the page named "second.asp". This work can be done by a form:

<form action="second.asp" method="post">         --------- destination
<input type="text" name="user">                  --------- name and value
<input type="submit" value="Send Query String">
</form>

There is an advantage for using form to send query string that you can enter any value into the text box without change the code in the page.

As you see, ASP can do something that can not be done by HTML. With HTML, you can not sent data from one page to another page, but ASP can do this work.

  Back to Index Page
Next Page >>   Introduction
ASP Tags and Include File
Response and Request
If Then
For Loop
Redirect
Sessiont
Use Database
 

ASP Books
ASP Jobs



Bookmark:  del.icio.us digg facebook Reddit Mixx BlinkList Fark Furl NewsVine Simpy Spurl Segnalo Technorati blogmarks Google YahooMyWeb Windows Live



ASP Course: Response and Request - www.itechcollege.com
Copyright ©2008, itechcollege.com. All rights reserved
iTechCollege | About iTech | Contact iTech