Front and Center: Creating Your Own Form Handler

In addition to the Send to File/E-mail handler and the Send to Database handler, FrontPage also allows you to connect a form to your own custom designed form handler via the Send to Other option on the Form Properties dialog box. When you select the Send to Other option, the dropdown next to it becomes active. The dropdown contains three choices:

  • Custom ISAPI, NSAPI, CGI, or ASP Script Sends your form results to a custom handler.

  • Discussion Form Handler Sends your form to the Discussion Form Handler. FrontPage uses this handler when you create FrontPage Discussion Web sites.

  • Registration Form Handler Sends your form to the FrontPage Registration form handler. FrontPage uses this handler when you create Registration pages.

The first option, Custom ISAPI, NSAPI, CGI, or ASP Script, allows you to create your own form handler and point the form to it. Development of ISAPI filters, NSAPI, and CGI components is beyond the scope of this book. Instead, we will create a simple form handler using ASP.

NOTE

For more information on ISAPI filters, read Internet Information Services Administration from Que Publishing.

For more information on NSAPI, see Netscape Communications's NSAPI Programmer's Guide at http://nsapi.frontpagelink.com.

For more information on common gateway interface, or CGI, read Special Edition Using CGI.

For more information on ASP, read Active Server Pages 3.0 From Scratch from Que Publishing.


The form handler you will build here is not a robust solution, but is meant to show you the framework provided for creating a custom ASP form handler. You will use the comment.htm page that you have been using throughout this chapter.

You will need to create a new ASP page to handle your form:

  1. Create a new page.

  2. Save the page as handle.asp.

  3. Type Your name is: NAME on the first line and press Enter.

  4. Type Your comments are: COMMENTS on the second line.

You will configure this page so that it will display the information that was entered in the form on comment.htm. Start by creating the ASP code necessary to display the values from the form fields:

  1. Switch to Code view.

  2. Replace NAME with the following ASP code:

     
     <% Response.Write Request.Form("txtName") %> 
  3. Replace COMMENTS with the following ASP code:

     
     <% Response.Write Request.Form("txtComments") %> 
  4. Save the page.

The handle.asp now contains ASP code that will display the values of the form fields txtName and txtComments. It does this using the Response.Write statement, which writes information to the browser window, and the Request.Form collection, which contains one item for each form field.

Now you simply need to point comment.htm to the new ASP page:

  1. Open comment.htm.

  2. Right-click the Submit button and select Form Properties.

  3. Choose the Send to Other option and make sure that Custom ISAPI, NSAPI, CGI, or ASP Script is selected.

  4. Click the Options button to display the Options for Custom Form Handler dialog box, as seen in Figure 18.31.

    Figure 18.31. The Options for Custom Form Handler dialog box lets you point your form to any handler you choose.

    graphics/18fig31.gif

  5. Replace --WEBBOT-SELF-- with handle.asp and leave the Encoding Type set to POST.

  6. Click OK in the Options for Custom Form Handler dialog box.

  7. Click OK in the Form Properties dialog box.

Now save your page and browse to comment.htm. Enter your information and click Submit, and handle.asp should appear with the values you entered in the form.



Special Edition Using Microsoft Office FrontPage 2003
Special Edition Using Microsoft Office FrontPage 2003
ISBN: 0789729547
EAN: 2147483647
Year: 2003
Pages: 443

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net