Share via


Forms Processing Code Flow for Solution Sites

There are three typical scenarios that result in different code flow:

  • Form is being shown for the first time
  • Form is submitted with data that is not valid
  • Form is submitted with valid data

Form is being shown for the first time

  1. The call to the IsFormSubmitted routine determines that the form is being shown for the first time.

  2. Call the htmRenderFillOutForm routine to prepare the HTML that will render the form. The parameters are as follows:

    urlAction

    Typically set to the page that the form is on (for pages that are self-validating).

    sFormName

    The name of the form.

    dictFieldVals

    A Dictionary object containing initial values for the form. Pass Nothing to create an empty form. For a pre-populated form, pass a dictionary with key/value pairs where the keys are the form field names, and the values are the initial values. The Solution Sites use the GetDefaultValuesForItemFields routines to build these dictionaries.

    dictMessages

    Set to Nothing.

Form is submitted with data that is not valid

  1. The call to the IsFormSubmitted routine determines that the form is being submitted.

  2. Call the GetSubmittedFieldValues routine to create a Dictionary object that contains the form field values submitted with the HTTP request. The one parameter is the field definition dictionary for the form.

  3. Call the GetFieldsErrorDictionary routine to perform field-level validation based on the passed field definition dictionary and the dictionary with field values returned by the call to the GetSubmittedFieldValues routine. If the returned Dictionary object is empty, no field-level validation errors were found.

  4. Perform any custom validation that is required, such as validation that requires database access, or cross-field validation. If the custom validation code associates error messages with particular form fields, it should write error messages into the same Dictionary object returned by the GetFieldsErrorDictionary routine. In the Solution Sites, the ValidateSubmittedItem routines perform this function.

  5. In this scenario, field validation errors were found in either step 4 or step 5 (or both). Call the htmRenderFillOutForm routine to prepare the HTML that will re-render the form so that the user can correct the invalid data. The parameters are as follows:

    urlAction

    Typically set to the page that the form is on (for pages that are self-validating).

    sFormName

    The name of the form.

    dictFieldVals

    A Dictionary object that can contain either the original default data for the form, or the posted data that includes the data that is not valid, or a combination of the two. You could also pass Nothing if it makes the most sense for the user to start from scratch.

    dictMessages

    A Dictionary object that contains error messages associated with the form fields that failed validation. This dictionary contains key/value pairs where the keys are the form field names, and the values are error messages that will be displayed below the form fields to which they correspond. If this parameter is set to Nothing, no such error messages will be displayed.

Form is submitted with valid data

  1. The call to the IsFormSubmitted routine determines that the form is being submitted.
  2. Call the GetSubmittedFieldValues routine to create a Dictionary object that contains the form field values submitted with the HTTP request. The one parameter is the field definition dictionary for the form.
  3. The call to the GetFieldsErrorDictionary routine performs field-level validation based on the passed field definition dictionary and the dictionary with field values returned by the call to the GetSubmittedFieldValues routine. It returns an empty Dictionary object, indicating that no field-level validation errors were found.
  4. Custom validation, normally performed by the ValidateSubmittedItem routines, determines that no other errors are present.
  5. Since no form field errors were found, accept the form submittal by processing the form data and proceeding to the next page (usually by re-directing to a different page).

Copyright © 2005 Microsoft Corporation.
All rights reserved.