This tutorial is the sixth part of the ASP.NET Validation tutorial series. This tutorial will demonstrate how to use the validation summary with ASP.NET 4.0.
What is the ValidationSummary?
The validation summary is an ASP.NET control that allows you to easily display validation error messages. It works by taking all of the validation error messages from an invalid page and displays them in a single location. The validation summary is used on pages that contain validators to simplify and organize error messages for the user.
Server Intellect assists companies of all sizes with their hosting needs by offering fully configured server solutions coupled with proactive server management services. Server Intellect specializes in providing complete internet-ready server solutions backed by their expert 24/365 proactive support team.
Using the ValidationSummary
To demonstrate the use of a validation summary, we will need to create a simple web page with a few validators on it. To do this, create a new ASP.NET Empty Web Site and:
We stand behind Server Intellect and their support team. They offer dedicated servers , and they are now offering cloud hosting!
Testing
To test this out, simply load up the page and click the button. Notice that the error messages are displayed at the bottom in the validation summary. Also, notice that the text property of our required field validators is now displayed next to the text boxes. This is because a validation summary is displaying the errors. If there were no validation summary on the page, the error message would be displayed next to the text boxes instead.
The validation summary is an ASP.NET control that allows you to easily display validation error messages. It works by taking all of the validation error messages from an invalid page and displays them in a single location. The validation summary is used on pages that contain validators to simplify and organize error messages for the user.
Server Intellect assists companies of all sizes with their hosting needs by offering fully configured server solutions coupled with proactive server management services. Server Intellect specializes in providing complete internet-ready server solutions backed by their expert 24/365 proactive support team.
Using the ValidationSummary
To demonstrate the use of a validation summary, we will need to create a simple web page with a few validators on it. To do this, create a new ASP.NET Empty Web Site and:
- Right click the project in your solution explorer.
- Select add new item...
- Select a web form.
- Name it 'Default.aspx'.
- Click add.
- Open Default.aspx up to design mode.
- Drag and drop a textbox onto the web form.
- Drag and drop a requiredfieldvalidator onto the web form.
- Change the ErrorMessage property to 'TextBox1 is required.'
- Set the ControlToValidate property to 'TextBox1'.
- Set the Text property to '*'.
- Add a break line.
- Drag and drop a textbox onto the web form.
- Drag and drop a requiredfieldvalidator onto the web form.
- Change the ErrorMessage property to 'TextBox2 is required.'
- Set the ControlToValidate property to 'TextBox2'.
- Set the Text property to '*'.
- Add a break line.
- Drag and drop a button onto the web form.
- Add a break line.
- Drag and drop a validationsummary onto the web form.
We stand behind Server Intellect and their support team. They offer dedicated servers , and they are now offering cloud hosting!
Testing
To test this out, simply load up the page and click the button. Notice that the error messages are displayed at the bottom in the validation summary. Also, notice that the text property of our required field validators is now displayed next to the text boxes. This is because a validation summary is displaying the errors. If there were no validation summary on the page, the error message would be displayed next to the text boxes instead.
No comments:
Post a Comment