Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
Dear Friends,
 
Am working on Asp.net, C#, SqlServer 2005.
 
I have Two logins on one page.
 
for Example : I have Teachers login and students login on one page.
 
In Teachers login I have Two Textboxes and Submit button and also
two textboxes and submit button in students login.
 
So, i have one validation summary for this two logins.
 
Please help me, how to validate separately for this two Logins.
 
Please help, THANKS IN ADVANCE.
Posted 24-Nov-12 20:40pm

1 solution

Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

You have to specify validation group for each Section. Try this.;
 
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title>Untitled Page</title>
</head>
<body>
    <form id="form1" runat="server">
    <div>
        <table>
            <tr>
                <td>
                    <asp:Panel ID="Panel1" runat="server" GroupingText="Teacher Login" Width="339px">
                        <asp:TextBox ID="TextBox1" runat="server" ValidationGroup="teacher"></asp:TextBox><asp:RequiredFieldValidator
                            ID="RequiredFieldValidator1" ErrorMessage="Please Enter teacher user name" ControlToValidate="TextBox1"
                            runat="server" ValidationGroup="teacher">*</asp:RequiredFieldValidator>
                        <asp:Button ID="Button1" runat="server" Text="Teacher Login" ValidationGroup="teacher" />
                        <asp:ValidationSummary ShowSummary="false" ID="ValidationSummary1" ShowMessageBox="true"
                            runat="server" ValidationGroup="teacher" />
                    </asp:Panel>
                </td>
                <td>
                    <asp:Panel ID="Panel2" runat="server" GroupingText="Student Login" Width="337px">
                        <asp:TextBox ID="TextBox2" runat="server" ValidationGroup="stu"></asp:TextBox>
                        <asp:RequiredFieldValidator ID="RequiredFieldValidator2" runat="server" ControlToValidate="TextBox2"
                            ErrorMessage="Please Enter Student user name" ValidationGroup="stu">*</asp:RequiredFieldValidator>
                        <asp:Button ID="Button2" runat="server" Text="Student Login" ValidationGroup="stu" />
                        <asp:ValidationSummary ID="ValidationSummary2" runat="server" ShowMessageBox="true"
                            ShowSummary="false" ValidationGroup="stu" />
                    </asp:Panel>
                </td>
            </tr>
        </table>
    </div>
    </form>
</body>
</html>
  Permalink  

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



Advertise | Privacy | Mobile
Web01 | 2.8.141220.1 | Last Updated 25 Nov 2012
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100