Home | Advertising Info19 USERS CURRENTLY ONLINE   
PowerASP
   Site Search Contact Us Monday, May 20, 2024  

  Active TopicsActive Topics  Display List of Forum MembersMemberlist  Search The ForumSearch  HelpHelp
  RegisterRegister  LoginLogin
Classic ASP - General
 PowerASP Code Help Area : Classic ASP - General
Subject Topic: Using Forms to send information between A Post ReplyPost New Topic
Author
Message << Prev Topic | Next Topic >>
cwilliams
Admin Group
Admin Group
Avatar

Joined: April/26/2004
Location: United States
Online Status: Offline
Posts: 137
Posted: 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 posts by cwilliams
 
Bullschmidt
Newbie
Newbie
Avatar

Joined: July/06/2004
Location: United States
Online Status: Offline
Posts: 12
Posted: 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 posts by Bullschmidt Visit Bullschmidt's Homepage
 

If you wish to post a reply to this topic you must first login
If you are not already registered you must first register

  Post ReplyPost New Topic
Printable version Printable version

Forum Jump
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot delete your posts in this forum
You cannot edit your posts in this forum
You cannot create polls in this forum
You cannot vote in polls in this forum

   Active Server Pages Rule The World
Contact Us  
All artwork, design & content contained in this site are Copyright © 1998 - 2024 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.

Active Server Pages help tutorial how to ASP Help ASP Tutorials ASP Programming ASP Code - ASP Free CJWSoft ASPProtect ASPBanner ASPClassifieds www.aspprotect.com, www.cjwsoft.com,www.aspclassifieds.com,www.aspphotogallery.com