Here is a example how to use validation group.
On clicking of Save Button,it should fire the Required Field validator of Name is required fields only. In the same way,on clicking Save Password it should fire
the Required Field validator only for Password is required fields.
For Group1
<asp:TextBox ID="txtusername" runat="server" ValidationGroup="Group1"></asp:TextBox>
<asp:RequiredFieldValidator ID="rfvUname" runat="server" ControlToValidate="txtusername"
ErrorMessage="Name is required." ValidationGroup="Group1">*</asp:RequiredFieldValidator>
<asp:Button ID="btnSave" runat="server" Text="Save" ValidationGroup="Group1" />
For Group2
<asp:TextBox ID="txtPassword" runat="server" TextMode="Password" ValidationGroup="Group2></asp:TextBox>
<asp:RequiredFieldValidator ID="rfvpass" runat="server" ControlToValidate="txtPassword"
ErrorMessage="Password is required." ValidationGroup="Group2">*</asp:RequiredFieldValidator>
<asp:Button ID="btnSavePass" runat="server" Text="Save Password" ValidationGroup="Group2" />
Thanks & Regards
Santosh
0 comments:
Post a Comment