Customizing the Default Error Message

You can change the data validation error message by setting the ErrorMessage and Text properties of a Validator control...This property is set at design time, but can be changed via the code generation tag’s Properties dialog.

March 15, 2006
Iron Speed Designer V3.2

Introduction
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. This property is set at design time, but can be changed via the code generation tag’s Properties dialog. To change it, you 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.

About the Author
Alan S. Fisher
Co-Founder and Chairman of Iron Speed, Inc.

Mr. Fisher was a General Partner at Outlook Ventures, Inc., a venture capital company prior to co-founding Iron Speed, Inc. He co-founded Onsale, Inc. (now part of Amazon) and was its Chief Technology Officer from July 1994 to December 1999. He also co-founded and was President of Software Partners, Inc, a developer and publisher of software products from August 1988 to July 1994. From April 1984 to August 1988, Mr. Fisher served as Technical Marketing Manager and Product Development Manager for Teknowledge, Inc., a developer of artificial intelligence software products. From June 1981 to April 1984, he served as a member of the technical staff for AT&T Bell Laboratories.

Mr. Fisher has served on the boards of several publicly traded companies including Onsale, Inc. (NASDAQ:ONSL), an Internet auction retailer; Egghead.com (NASDAQ:EGGS), an Internet retailer of computers and software; FatBrain, Inc. (NASDAQ:FATB), an Internet retailer of technical and professional books; and Infodata Systems Inc. (NASDAQ:INFD), an e-business consulting services company.

Mr. Fisher received his B.S. in Electrical Engineering from the University of Missouri and received his M.S. in Electrical Engineering from Stanford University.



  Privacy Statement