<html xmlns="http://www.w3.org/1999/xhtml ">
<head runat="server">
<title>有选择性验证某些控件</title>
<style type="text/css">
</style>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:TextBox ID="txtcontentone" runat="server"></asp:TextBox>
<asp:RequiredFieldValidator ID="rfvContentone" runat="server" ValidationGroup="GroupOne" ControlToValidate="txtcontentone" ErrorMessage="ContentOne can't null">*</asp:RequiredFieldValidator>
<asp:TextBox ID="txtcontenttwo" runat="server"></asp:TextBox>
<asp:RequiredFieldValidator ID="rfvContentTwo" runat="server" ValidationGroup="GroupOne" ControlToValidate="txtcontenttwo" ErrorMessage="ContentTwo can't null">*</asp:RequiredFieldValidator>
<asp:TextBox ID="txtcontentthree" runat="server"></asp:TextBox>
<asp:RequiredFieldValidator ID="rfvContentThree" runat="server" ValidationGroup="GroupTwo" ControlToValidate="txtcontentthree" ErrorMessage="ContentThree can't null">*</asp:RequiredFieldValidator>
<asp:Button ID="btnGroupOne" runat="server" ValidationGroup="GroupOne" Text="验证GroupOne" οnclick="btncontent_Click"/>
<asp:Button ID="btnGroupTwo" runat="server" ValidationGroup="GroupTwo" Text="验证GroupTwo" />
<asp:ValidationSummary ID="vsGroupOne" runat="server" ShowMessageBox="true" ShowSummary="false" ValidationGroup="GroupOne"/>
<asp:ValidationSummary ID="vsGroupTwo" runat="server" ShowMessageBox="true" ShowSummary="false" ValidationGroup="GroupTwo"/>
</div>
</form>
</body>
</html>