Page 211 - DCAP408_WEB_PROGRAMMING
P. 211

Unit 8: ASP Web Forms




          Each text box, list box, check box or radio button in a form is a field. We need a way to create  Notes
          form fields within our form.

          8.1 Using Form Fields


          To create text boxes, check boxes, and radio buttons, we should use <INPUT> tag. The <INPUT>
          tag has a number of properties, but we will only concentrate on the following three:
              NAME- The name tag uniquely identifies each element in the form.

              TYPE- The TYPE tag determines what type of form field is displayed. To display a text box,
               we should set TYPE equal to TEXT. To create a check box we should assign TYPE equal to
               CHECKBOX.

              VALUE- The value tag determines the default value for the form field. This property is
               important when processing the information submitted by list boxes, check boxes, and
               radio buttons.

          Designing Forms

          A few things are important worth considering before designing form:
          1.   To make sure that the form has a submitting button.
          2.   The form  should be easy for  the user to complete. We have four form  fields at  your
               disposal: the text box list box check box and radio button. Make sure that the type of form
               field used best fits the information needing to be collected. For example, if we are going
               to ask for a user’s mailing address it makes more sense to have a list box that contains the
               50 states than to have the user type in the name of his or her state of residency.


                 Example: The first thing to do is to ask,” What information do I need from the user?” In
          this case the information needed would be user’s name, street address, city, state and zip code.
          We may also want to obtain some background information on the user as well, such as how
          often he purchase widgets.

          Based on these understandings we need following form fields:
              Text boxes would work well for entering the first and last names of the customer, as well
               as for the street address and zip code.

              A list box should be employed so that the users can select their states, instead of typing
               state names or postal abbreviations list box, containing 50 states, may seem unwieldy, but
               resist the temptation to use a text box. When using a text box, we are allowing users to
               enter anything, where a list box requires them to choose one of the viable options. If users
               are permitted to type in the names of their states, several different values can be received
               for one particular state.

              Radio buttons would work  well for  the background  information on the user’s widget
               buying habits.
              A simple check box would suffice for the online newsletter subscription.

          Send Information by Using Forms

          A common use of intranet and Internet server applications is to process a form submitted by a
          browser. With ASP,  we can embed scripts written in VBScript directly into an HTML file to
          process the form. ASP processes the script commands and returns the results to the browser.



                                           LOVELY PROFESSIONAL UNIVERSITY                                   205
   206   207   208   209   210   211   212   213   214   215   216