Skip navigation FileNet logo
  Open Client Developer's Guide
  Search  |  Index  |  Glossary   |  
Open menu Overview
Open menu Open Client Architecture
Open menu Developing for Process
Close menu Error and Exception Handling
  Close menu Error Handling
    ASPX Pages
    User Controls
  Open menu Exception Handling
Open menu Customizing the Framework
Globalization / Localization
Open menu General Information
   

Error Handling by User Controls

User Controls are normally used for displaying data or getting input from the users. ASP.NET provides a variety of Validators that can assist with validating the data in the controls. TheValidators are not displayed in the page when the data supplied by the user is valid. The error messages are only displayed when the data and control to be validated do not meet the the condition(s) specified by the Validator. Another feature of using Validators is that the initial validation is performed on the client side, preventing a performance hit back to the server.

Follow these steps to implement User Control Validators:

  1. Add the Validator to the left of the control to be validated. Also, initialize the ErrorMessage property of the Validator with the localized string.
  2. As an example, inspect the TBUserName control in the Login Page.  A RequiredFieldValidator can be used to validate this field because it is a required field.

    <asp:TextBox id="TBUserName" runat="server"></asp:TextBox>
    <asp:RequiredFieldValidator id="RequiredFieldValidator1" runat="server"
       ErrorMessage="Please enter a name." ControlToValidate="TBUserName">
    </asp:RequiredFieldValidator>

  3. When the Login button is pressed, if the TBUserName control is empty, the RequiredFieldValidator Validator will display the error message and block the form from being sent to the server.

Control Factory controls also use Validators to validate most of the simple-value controls. These controls are configurable by specifying which property of the control should be validated, prior to sending the data to the server.

Pages that don’t use Control Factory controls, can use standard Validators to validate control data as applicable. To validate other, non-UI related errors, follow the error handling mechanism for the foundation classes as described in How Errors are Handled by Data Providers and Foundation Classes.