Customizing the Default Error Message

Updated June 5, 2006
Iron Speed Designer V3.2 and V4.0

You can change the data validation error message by setting the ErrorMessage and Text properties of a Validator control.  The ErrorMessage property of a validation control is displayed in a pop-up window while the Text property is displayed at the location of the validator on the web page.  These properties are set at design time, and can be changed via the code generation tag’s Properties dialog.  To change it, simply add or modify the pass-through attributes located under the Properties tab of the FieldValue tag.

The following example illustrates how to change or replace the default error message text for the Product Name field in the AddProductRecord.aspx page in a sample application.  The default error message would say, ‘A value for Product Name is required’.

Generated Page

If you try to add a new record without a Product Name, you will see your custom error message displayed like this:

Procedure

Step 1:  In the AddProductRecord page’s Properties dialog, select the ProductName FieldValue tag.

Step 2:  From the Attributes tab, add or modify the attributes that begin with “ProductNameRequiredFieldValidator:” to specify the properties of the tag’s RequiredFieldValidator.  For a more generic example:

Pass-Through Attribute

Value

<YourFieldName>RequiredFieldValidator:Enabled

True

<YourFieldName>RequiredFieldValidator:ErrorMessage

A value for Product Name is required to process your order.

Enter a custom error message of your choosing.

<YourFieldName>RequiredFieldValidator:Text

*

(asterisk character)

Step 3:  Build and run the application.

See Also

Part V: Customizing Generated Application Code