dcsimg

4 Ways to send/get Information from an ASP/HTML to another ASP

By ServerWatch Staff (Send Email)
Posted Apr 22, 1999


Joco Vieira

This one I think it will help many people , it was one of my biggest problems when I started some more advanced web programming a couple of years ago. What I am showing here is many ways to send the variables name and phone from one HTML/ASP to an ASP.

This one I think it will help many people , it was one of my biggest problems when I started some more advanced web programming a couple of years ago. What I am showing here is many ways to send the variables name and phone from one HTML/ASP to an ASP.


1. Well like I said the variables are 'name' and 'phone', of course you can use any variable you like.
     At this first example we use the GET method, this one will show all the information on the link address,
    like"http://www.anything.com/getting.asp?name=thenamewritten&phone=phonewritten

FILE : SENDING.HTML
<form name="sending" method="GET" action="getting.asp" target="_self">

</FONT><font size="2">Name :</font><br>
<input name="name" size="22" >
<br>
<font size="2">Phone:</font><br>
<input name="phone" size="14" >
<br> 
<input type="submit" value="Send" name="Send">

</form>

FILE : GETTING.ASP
        ' the querystring gets the info that it is attached at the link address
        gotname = Request.querystring("name") '
        gotphone = Request.querystring("phone")

2. Here I use the POST method, the one I use most, its more confidencial
and doesn't show the variables content.

FILE : SENDING.HTML
<form name="sending" method="POST" action="getting.asp" target="_self">

</FONT><font size="2">Name :</font><br>
<input name="name" size="22" >
<br>
<font size="2">Phone:</font><br>
<input name="phone" size="14" >
<br> 
<input type="submit" value="Send" name="Send">

</form>


FILE : GETTING.ASP
<%
        ' the request.form gets the info within the boxes of the form actioned
        ' from the previous HTML/ASP
        gotname = Request.form("name") '
        gotphone = Request.form("phone")

%>

3. Here i use something like the first example, the big difference is that you say wich variables to send.

FILE : SENDING.ASP

<%
    name2 = "Thename I want"
    'or name2 = recordsetobject("name") yes you can get info from DB
    ' or make Calculations before
   phone2 = "1232131221"

%>

  <a href="getting.asp?name=<%=name2%>&phone=<%=phone2%>" target="_self" ><img src="images/button_gotogetting.gif" name="pic"></a>


FILE : GETTING.ASP

<%
        gotname = request.querystring("name")
        gotphone = request.querystring("phone")
%>

 

4. This way you make a button, or an image that the HREF is the link with the info you want to send. I use some predefined information
as two variables, such as name and phone, remember this two variables can be first taken from an DB and then used to href.
I use here the session argument, it is very usefull to its purpose, its something like the global variables of the ASP pages, you create one,
and while your browsing between the pages the variable exists, or even reloading the same page.


FILE : SENDING.ASP

<%
    session("name") = "Myname"
    session("phone") = "21121231"

%>
<a href="getting.asp" target="_self" ><img src="images/button_gotogetting.gif" name="pic"></a>


FILE : GETTING.ASP

<%
        gotname = session("name")
        gotphone = session("phone")
%>

 

And thats All 4 ways for you to trade information between ASPs.

Page 1 of 1


Comment and Contribute

Your name/nickname

Your email

(Maximum characters: 1200). You have characters left.


 

 


Thanks for your registration, follow us on our social networks to keep up-to-date