About Me

Friday 20 April 2012

ASP Forms Get

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.

nullvoid.html Code:

<form method="GET" action="nullvoidGet.asp">
Name <input type="text" name="Name"/>
Age <input type="text" name="Age"/>
<input type="submit" />
</form>
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:

0 comments:

Post a Comment