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
Free Courses
HTML
JavaScript
CSS
ASP
PHP
JSP
C++
ASP.NET
SQL
AJAX
FTP
XML

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


Online Education, Online Training for Your Job, Distance Education, E-learning Programs for Your Career!Online Colleges, Online Universities, E-learning & Distance Education for Your Career! Easy Job Training & Online Courses.


   Email A Friend  
 
Earn Online Degree
for Your Job
I found a job after I earned an online degree!
Online classes for finding a Job. Online College, Online University, Degrees, E-learning school, online certificate Earn your
online degree now!
Online Training
for Good Job
Why I work so hard but earn so little? Why I cannot find a high paying job?
Online training for a Good Jobs. Online Degree, E-learning school, online certificate Go to
online school now!

Copyright ©2024, itechcollege.com. All rights reserved
iTechCollege | About iTech | Contact iTech