Bookmark and Share

ASP Forms Get

When you pass information from an HTML form, using the Get method, to an ASP page from processing, you can retrieve the information using ASP's QueryString Collection. In the previous lesson we created "tizagForm.html" that sent information to "tizagGet.asp" for processing. Below is that HTML code.

Advertise on

tizagForm.html Code:

<form method="GET" action="tizagGet.asp">
Name <input type="text" name="Name"/>
Age <input type="text" name="Age"/>
<input type="submit" />

Now we need to create our ASP web page "tizagGet.asp" that will process this data.

ASP QueryString Variables

The form data we want resides within the Request Object's QueryString collection. In this collection there is an entry for each individual Form Input from our HTML Form. The input tag's name attribute is the key needed to access data for that Input element.

Here we create a simple ASP processor that will store the contents of each the two items in our QueryString into variables and then print their values to the web page.

Save your ASP file as "tizagGet.asp" and save it in the same directory as "tizagForm.html".

tizagGet.asp Code:

Dim name, age
name = Request.QueryString("Name")
age = Request.QueryString("Age")
Response.Write("Name: " & name & "<br />")
Response.Write("Age: " & age & "<br />")

ASP Get Simulation

After you have saved both files into a working ASP directory then if you were to enter the following information into "tizagForm.html" and submit you would get the following:

tizagForm.html Filled Out:

Name Age

tizagGet.asp Result:

Name: Fred
Age: 52
Bookmark and Share

Found Something Wrong in this Lesson?

Report a Bug or Comment on This Lesson - Your input is what keeps Tizag improving with time!

Advertise Here

More Tutorials!
Microsoft Office Tutorials Artist Tutorials