Wife/Girlfriend/Sister?
Pepper Spray &
Stun Gun Specials!
KEEP THEM SAFE.
 CoverYourASP --> Implementing forms with ASP --> Part 3

Free membership

Join in the fun! Sign in
Member Services

Site navigation
Download the entire site!
Search my articles
Free Magazines
Browse the directory

Send me feedback
Buy my boxer shorts

Recommend this page
Printer-friendly page

Resources I recommend
Link to my site
Advertising slashed!
About your privacy
Legal stuff
Site statistics
16 active users
3 visitors today
10 pages today
how is this done?
Tools I use

CoverYourASP
Copyright © 1999-2012 James Shaw.
All rights reserved.

ASP.NET Blog
RSS submissions
E-commerce

Now open source with SourceForge!

Displaying the form

// show the form if not submitted yet
if ( !bSubmitted )
{
   Out ( 'Here\'s a simple form.' );

So, on to displaying the form. In this case I want to display the form only when the form hasn't been submitted yet, but of course you could remove the "if" and display the form again every time - my search form does that.

Note that as discussed earlier, bSubmitted will also be false if the form has been submitted with invalid data, so the form will refresh with the submitted values intact, ready for the user to fix the errors.

   Out ( '<form action="FormPage.asp" method="post">' );

The <form< tag has two main attributes - action and method.

action defines which page to call when the form is submitted. You can hardcode your page name as I have, or you can make the form easier to maintain by using the name of the current page held in the ServerVariables collection, as shown below:

   Out ( '<form action="' + Request.ServerVariables ( 'SCRIPT_NAME' ) + '" method="post">' );

Note that the ServerVariables collection is quite "expensive" the first time you use it on a page - although it contains many useful values, please use sparingly.

The method attribute can have two values, get and post. Only in very rare cases will you want to use get - since it uses the URL to submit the values it is limited to 255 characters of data, is very insecure, and ugly!

post, on the other hand, passes the values in the HTTP headers where it cannot be seen, and the limit is much higher.

Part 4: <form> inputs...

Featured sponsor
My favorite resources

Tiki Statues - Tiki Masks - Tiki Totems



New Proposal Kit Professional 5.1
Brand yourself as a top professional: create quotes and amazing proposals and get many legal documents free!

The latter saved me 3 times the purchase price on the first day I owned it!


I share my content

Supporting ASPRSS

Do you need a quick and easy way to link to my articles? All the information you need is published with ASPRSS...