Using the ValidationSummary Control

ASP.NET comes with a great set of validation controls, which can be invaluable to any developer wanting to maintain the integrity of their application.  If you do not use validation controls you really need to start incorporating them into your application ASAP.

Finding the Validation Summary in Visual Studio 2003One validation control that I rarely ever see used is the ValidationSummary control.  I think part of the reason why is there are next to no examples using this control.  It can be a pretty useful control and offers us some special behaviors to make out data validation better for end users.  Two good things it provides is the listing of all error messages on the page where our user may be focused.  Another is that is can display a pop-up dialog listing all the invalid data to our user when the form is submitted.  Both of these mechanisms are optional and can be set at design time.

Validation Summary in Visual Studio 2003To use the ValidationSummary Control you will need to place it on your page in a useful location.  You will want to determine where the user will be focused when the page is posted-back to the server, which may be the top of a long form and not at the button they just clicked.  You can experiment to determine the best location for your form.

Using the Validation Summary in Visual Studio 2003You will need to set the properties of the control.  You can determine what type of display will be echoed on the page and if you want the summary to be echoed from the control at all.  The list options are List, Bulleted List and a single paragraph.  If you choose to not Show the Summary the validation controls you have on the page will display the error messages as if you did not have the summary control.  If you choose to Show the Summary you can enter text each validation control, like an *, that will be displayed instead of the ErrorMessage.

Validation Summary Error Message Pop-Up DialogAnother option is to display a dialog to the user with the summary of the error messages.  This is a real useful option since the user will certainly be aware of the invalid or missing data.  I think if you choose this option you may want to display the Show Summary option, but that will be a personal choice.

Share This Article With Your Friends!

Googles Ads Facebook Pixel Bing Pixel LinkedIn Pixel