Login | Register   
LinkedIn
Google+
Twitter
RSS Feed
Download our iPhone app
TODAY'S HEADLINES  |   ARTICLE ARCHIVE  |   FORUMS  |   TIP BANK
Browse DevX
Sign up for e-mail newsletters from DevX


advertisement
 

Validating Data On Web Forms : Page 7

There are six validation controls included with ASP.NET as well as a summary control. Data validation with the ASP.NET validation controls is always processed on the Web server and can also optionally be processed on the user's computer.


advertisement
ValidationSummary Control
The ASP.NET ValidationSummary control differs from the other validation controls in that it does not perform data validation directly. Instead, the ValidationSummary control displays a summary list of error messages from any of the validation controls on the current Web form that fail data validation. You don't need to link the ValidationSummary control to the other Web controls or validation controls on the page. In the HTML snippet below, I declare a ValidationSummary control with many of the most commonly specified attributes shown.

<asp:ValidationSummary DisplayMode="BulletList" ID="vsValidationExample" RunAt="Server" ShowMessageBox="True" ShowSummary="True" HeaderText="CoDe Magazine Validation Controls Example" />

The snippet above features several new attributes. The DisplayMode attribute determines the format of the summary list that the ValidationSummary control will display. The possible values for the DisplayMode attribute are BulletList, List, and SingleParagraph. The BulletList value displays each data validation failure as a separate bullet item in a bulleted list. The List value displays each data validation failure as a separate line item in a non-bulleted list. The SingleParagraph value displays each data validation failure as a separate sentence delimited by periods in a single paragraph format.

The ShowMessageBox attribute determines whether you want a message box to pop up in the user's browser that displays the data validation failure items. The possible values for the ShowMessageBox attribute are true and false. The ShowSummary attribute determines whether you want a summary of the data validation failure items to display on the current Web form at the location where you've declared the ValidationSummary control. The possible values for the ShowSummary attribute are true and false.

The HeaderText attribute defines an optional line of header information that you can display above the list of data validation failure items. In both the popup message box and the on page summary, the header line will display just above the items summary.

Figure 7 shows an excerpt from the sample page where I show the ValidationSummary control in all three of the DisplayMode states. Figure 8 shows the popup message box that the ValidationSummary control displays.



Comment and Contribute

 

 

 

 

 


(Maximum characters: 1200). You have 1200 characters left.

 

 

Thanks for your registration, follow us on our social networks to keep up-to-date