So, our requirement can be achieved by the validation group
property in ASP.Net 2.0. The ASPX page will like,
<tr>
<td style="width: 100px">
First Name</td>
<td style="width: 100px">
<asp:TextBox ID="txtFirstName" runat="server"
ValidationGroup="Name_Group"></asp:TextBox></td>
</tr>
<tr>
<td style="width: 100px">
</td>
td style="width: 100px">
<asp:RequiredFieldValidator
ID="RequiredFieldValidator1" runat="server" ControlToValidate="txtFirstName"
ErrorMessage="Enter First Name"
ValidationGroup="Name_Group"
Width="149px"></asp:RequiredFieldValidator></td>
</tr>
<tr>
<td style="width: 100px">
Last Name</td>
<td style="width: 100px">
<asp:TextBox ID="txtLastName" runat="server"
ValidationGroup="Name_group"></asp:TextBox></td>
</tr>
<tr>
<td style="width: 100px">
</td>
<td style="width: 100px">
<asp:RequiredFieldValidator
ID="RequiredFieldValidator2" runat="server" ControlToValidate="txtLastName"
ErrorMessage="Enter Last Name"
ValidationGroup="Name_Group"Width="152px"></asp:RequiredFieldValidator></td>
</tr>
<tr>
<td style="width: 100px">
<td style="width: 100px">
<asp:Button ID="btnSaveName" runat="server" Text="Save
Name" ValidationGroup="Name_Group" /></td>
</tr>
Now,When I click “Save name” the output will be like,
And when I click “Save Address” the out put will be like
|