Page

3.1.0- Getting Information From the User

  by NT Community Manager.
Last Updated  by Jim Minatel.  

PublicCategorized as 03. Basic ASP Techniques.

Not tagged.
<< 3.0.0- Basic ASP TechniquesChapter33.1.1- Using a Form to Obtain Information from the User >>

Getting Information From the User

In the first chapter of this book, we discussed what ASP can do, and in the second chapter we looked at how to indicate to the web server exactly which sections of your HTML page are ASP code. Our first example in Chapter 1 just demonstrated how ASP works on your server. The simple text and HTML tags plus ASP code that you wrote, with the help of ASP on the server, generated an appropriate page, which returned the current time on the server. Two visitors requesting the page at different times on the same day will actually get two different pages back.

Now let's consider some real situations in the business world:

 

  • We would like to ask the user which product they are interested in and then have ASP generate a page specific to that interest.
  • We want to ask a visitor if they are a member of the organization. If they are, then they get a page that displays the organization's calendar. If not, they get a form, which they can complete and submit in order to join the club.
  • We have a page that uses advanced HTML techniques (such as formatting), which do not show up well in some browsers. We would like to establish which browser this visitor is using, and then send out a page of information formatted appropriately for that browser.
  • We want to give the visitor a tour of pages displaying this week's featured items. The user will proceed through the site by clicking on Next buttons. However, we want to update our pages weekly, so we need ASP to check our current list of pages featuring items and insert hyperlinks for those pages into the Next buttons at the moment the page goes to the user.

 

In each of these cases, we want to do some action beyond simply serving a page. We'll either need to make a decision about what page to serve, or we'll need to create a customized page for that particular request.

 

In order to make our decision we need to get some information from the user. In the first case, we need to know what product the user wants to see. In the second case we need to know if the user is a member or not. In the programming world this kind of information is considered as input. ASP needs input from the user in order to make its decisions.

 

Suppose that our web site has a 'page 1', which asks the user whether they want 'retail information' or 'wholesale information'. Once the user has selected from these options, how do we get that information from 'page 1' into the ASP of the second page? The simplest technique is to use a feature of HTML called the form. An HTML form performs four tasks:

 

  • <FORM> tags can ask the user for information and provide a text box or check box into which the user can type or select the answer
  • The form has a button, for submitting information back to the server
  • The submission has instructions to open a new page (usually an ASP page)
  • The submission also carries the information that the user typed into the fields which is to be used by the ASP code of the new page

 

We use forms to provide a means for users to input data to the server – the information that we need in order to make decisions in ASP.

 

If you are unfamiliar with forms and their methods for submitting information, then please refer to Appendix F for a comprehensive tutorial on forms.

<< 3.0.0- Basic ASP TechniquesChapter33.1.1- Using a Form to Obtain Information from the User >>

Copyright © 2003 by Wiley Publishing, Inc.

Powered by Near-TimeTerms of Services | Privacy Policy | Security Policy |