Click here to Skip to main content
15,885,216 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
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

1 solution

You have to specify validation group for each Section. Try this.;

XML
<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>
 
Share this answer
 

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



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900