Home | Advertising Info105 USERS CURRENTLY ONLINE   
PowerASP
   Site Search Contact Us Wednesday, January 15, 2025  

  Active InfoActive Info  Display List of Info MembersMemberlist  Search The InfoSearch  HelpHelp
  RegisterRegister  LoginLogin
Classic ASP - General
 PowerASP Code Help Area : Classic ASP - General
Subject Info: Using Forms to send information between A A d d  -  P o s tAdd P o s t
Author
Message << Prev Info | Next Info >>
cwilliams
Admin Group
Admin Group
Avatar

Joined: April/26/2004
Location: United States
Online Status: Offline
Info: 137
Added: April/27/2004 at 8:10pm | IP Logged Quote cwilliams

Using Forms to send information between ASP Pages

Many beginner ASP programmers have a hard time with this concept. Here is an example if you want to use forms to transfer information between ASP pages. It is actually very simple and is used quite often when building ASP applications.

Using a Form With Post

<form action="somepage.asp" method=POST>
   <input type ="text"
value ="somevalue" name ="somevariable">
   <input type=submit>
</form>


Supports more characters than GET or PUT
The page the form is submitted to will not show the parameters in the address window

The ASP page the form is submitted to uses the following code to retrieve the variable

<% somevariable = Request.Form("somevariable") %>


 

Using a Form with GET or PUT


<form action="somepage.asp" method=GET>
   <input type ="text"
value ="somevalue" name ="somevariable">
   <input type=submit><input type=reset>
</form>


The number of characters is limited
The page the form is submitted to will show the parameters in the address window
The ASP page the form is submitted to uses the following code to retrieve the variable

<% somevariable = Request.Querystring("somevariable") %>


Something To Think About
You can simply use Request("somevariable")
and it will retrieve it from the header no matter which of the 3 methods you used. This is probably a little slower but it makes for easier coding if you are not worried about milliseconds of time savings.

Also some versions of IE on the MAC do not work with "PUT" and will give you a 404 error, so it is probably best just to use "GET" though it is definitely a bug that they never seem to fix.



__________________


Chris Williams
http://www.PowerASP.com
Back to Top View cwilliams's Profile Search for other info by cwilliams
 
Bullschmidt
Newbie
Newbie
Avatar

Joined: July/06/2004
Location: United States
Online Status: Offline
Info: 12
Added: July/06/2004 at 12:41am | IP Logged Quote Bullschmidt

And often it's nice to have pages "post back" to themselves and then handle further processing from there.  This can often cut down on the number of pages that need to be developed and the related back-and-forth involved with many pages.

To make the form post back to the same page:
<form id="frmMain" name="frmMain" action="<%= Request.ServerVariables("SCRIPT_NAME") %>" method="post">

And here are some buttons:
<% ' *** btnClose %>
<input type="submit" name="btnClose" value="Close">
<% ' *** btnSave %>
<input type="submit" name="btnSave" value="Save">
<% ' *** btnNew %>
<input type="submit" name="btnNew" value="New">
<% ' *** btnDel %>
<input type="submit" name="btnDel" value="Delete" onclick="return confirm('Are you sure you want to delete this record?');">

To handle processing toward the top of the page:
If Request.Form("btnClose") <> "" Then  ' Close btn.
 ' Close.
 Call ClosePg()
Elseif Request.Form("btnSave") <> "" Then  ' Save btn.
 ' Set var.
 Call SetVar("frompost")

 ' Save rec.
 Call SaveRec()
Elseif Request.Form("btnNew") <> "" Then  ' New btn from this pg.
 ' Set var.
 Call SetVar("new")
Elseif Request.Form("btnDel") <> "" Then  ' Del btn.
 ' Set var.
 Call SetVar("frompost")

 ' Del rec.
 Call DelRec()

 ' Set var.
 Call SetVar("new")
Elseif Request.QueryString("CustID") <> "" Then ' CustID from Many pg.
 ' Set var.
 Call SetVar("fromdb")
Elseif Request.QueryString("CustID") = "" Then  ' Add btn from MainMenu pg.
 ' Set var.
 Call SetVar("new")
End If

And the ClosePg(), DelRec(), SaveRec(), and SetVar() functions above are custom functions that would still need to be developed.



__________________
J. Paul Schmidt, Freelance ASP Web Developer
www.Bullschmidt.com
Classic ASP Design Tips, ASP Web Database Sample (Freely Downloadable)
Back to Top View Bullschmidt's Profile Search for other info by Bullschmidt Visit Bullschmidt's Homepage
 

If you wish to make a comment to this info you must first login
If you are not already registered you must first register

  A d d  -  P o s tAdd P o s t
Printable version Printable version

Info Jump
You cannot add new info in this area
You cannot add to info in this area
You cannot delete your info in this area
You cannot edit your info in this area
You cannot create polls in this area
You cannot vote in polls in this area

   Active Server Pages Rule The World
Contact Us  
All artwork, design & content contained in this site are Copyright © 1998 - 2025 PowerASP.com and Christopher J. Williams
Banner ads ,other site logos, etc are copyright of their respective companies.
STATS Unless otherwise noted - All Rights Reserved.

PowerASP active server pages asp.net microsoft .net framework sdk learn asp what is asp tutorial learn asp.net CJWSoft ASPProtect ASPBanner ASPClassifieds www.aspprotect.com, www.cjwsoft.com,www.aspclassifieds.com,www.aspphotogallery.com