Easy-to-follow video tutorials help you learn software, creative, and business skills.Become a member
The ASP.NET Framework includes a control called the Validation Summary. The purpose of the Validation Summary is to collect all of the error messages generated by all of the validators within a particular page, and then to display those messages in a single location on the page. For this demonstration I'll use a file called TitleInsertValidationSummary.aspx. In the current version of the page there are three validator controls. Two of them on the Price field and one on the PubDate. If I simply click the Insert link, I'll see the error message for the price displayed. And if I type in a non-date value like xyz, I'll also see the validator for the pubdate displayed.
By using the Validation Summary, I'll collect these messages and display them in a single bullet list below the form. I'll close the browser and return to Visual Web Developer. The first step is to suppress the automatic output of the validator controls. I'll go to each of the validator controls in Source View and I'll change the Value of the validator controls Display property from Dynamic to None. And I'll do the same thing for the RangeValidator for price. And I'll also do the same thing for the RangeValidator for the pubdate.
Now if the form is displayed and the user makes errors, they won't see any messages at all. So here is how we replace that functionality. I'll look at the page in Design View and then I'll go to the Toolbox panel. One of the items in the Toolbox panel is called Validation Summary. Pin the Toolbox panel into place if it isn't already pinned, and then click into the paragraph to the right of the Details View and press Enter to create a new paragraph. Then drag the Validation Summary and place it in the empty paragraph. Notice that the Validation Summary by default displays in a bullet list. Now save your changes and run the page in the browser.
I will click the Insert link and show that the error message is now displayed below the form. And if I type in a non- date value into the PubDate filed and click Insert, I'll see both of the error messages displayed together. From this point on everything else is just a matter of simple formatting. If you don't like the extra space below the form eliminate any extra paragraphs. If you don't like the color, background, or anything else about the way that the control is displaying the error messages, create a Cascading Style Sheet class and set the CssClass property of the Validation Summary control to use that class. This way you can create a common interface for your entire website without having to set the same properties over-and-over.
So again, the purpose of the Validation Summary is to collect all of the error messages from all validator controls that are outputting them in a single page. You have to expressly suppress the output of the individual validator controls by setting their display property to None. And then add your Validation Summary wherever you wanted to display on your webpage.
Get unlimited access to all courses for just $25/month.Become a member
82 Video lessons · 101993 Viewers
61 Video lessons · 88702 Viewers
71 Video lessons · 72528 Viewers
56 Video lessons · 104187 Viewers
Access exercise files from a button right under the course name.
Search within course videos and transcripts, and jump right to the results.
Remove icons showing you already watched videos if you want to start over.
Make the video wide, narrow, full-screen, or pop the player out of the page into its own window.
Click on text in the transcript to jump to that spot in the video. As the video plays, the relevant spot in the transcript will be highlighted.
Your file was successfully uploaded.