Verify the use of controls 7 (validationsummary)

Source: Internet
Author: User
 1 <p>First name 
2 <asp:TextBox ID="TextBox1" Runat="server"></asp:TextBox>
3 &nbsp;
4 <asp:RequiredFieldValidator ID="RequiredFieldValidator1"
5 Runat="server" ErrorMessage="You must enter your first name"
6 ControlToValidate="TextBox1"></asp:RequiredFieldValidator>
7  </p>
8  <p>Last name
9 <asp:TextBox ID="TextBox2" Runat="server"></asp:TextBox>
10 &nbsp;
11 <asp:RequiredFieldValidator ID="RequiredFieldValidator2"
12 Runat="server" ErrorMessage="You must enter your last name"
13 ControlToValidate="TextBox2"></asp:RequiredFieldValidator>
14 </p>
15 <p>
16 <asp:Button ID="Button1" OnClick="Button1_Click" Runat="server"
17 Text="Submit"></asp:Button>
18 </p>
19 <p>
20 <asp:ValidationSummary ID="ValidationSummary1" Runat="server"
21 HeaderText="You received the following errors:">
22 </asp:ValidationSummary>
23 </p>
24 <p>
25 <asp:Label ID="Label1" Runat="server"></asp:Label>
26 </p>
1 <asp:RequiredFieldValidator ID="RequiredFieldValidator1" 
2 Runat="server" ErrorMessage="You must enter your first name" Text="*"
3 ControlToValidate="TextBox1"></asp:RequiredFieldValidator>
4
5 or
6
7 <asp:RequiredFieldValidator ID="RequiredFieldValidator1"
8 Runat="server" ErrorMessage="You must enter your first name"
9 ControlToValidate="TextBox1">*</asp:RequiredFieldValidator>

In this way, there will be no repeated display

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.