Wednesday 8 October 2014

Validation Summary Control in Asp.Net C#

No comments    
categories: ,
VALIDATION SUMMARY


The ValidationSummary control does not perform any validation but shows a summary of all errors in the page.
 The summary displays the values of the ErrorMessage property of all validation controls that failed validation.

                     DEMO




                          Html Coding


<html xmlns="http://www.w3.org/1999/xhtml">
<head id="Head1" runat="server">
    <title></title>
</head>
<body>
    <form id="form1" runat="server">
    <div>
    <table>

                <tr><td>
            <asp:Label ID="Label2" runat="server" Text="Email ID"></asp:Label>
            </td><td>
                <asp:TextBox ID="txtEmail" runat="server"></asp:TextBox>
                <asp:RegularExpressionValidator ID="RegularExpressionValidator1"
                    runat="server" ControlToValidate="txtEmail"
                    ErrorMessage="Invalid Email ID"
                    ValidationExpression="\w+([-+.']\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*"
                     SetFocusOnError="True"></asp:RegularExpressionValidator>
            </td></tr>

        <tr><td>
            <asp:Label ID="Label1" runat="server" Text="Password"></asp:Label>
            </td><td>
                <asp:TextBox ID="txtPassword" runat="server"></asp:TextBox>
                <asp:CompareValidator ID="CompareValidator1"
                    runat="server" ControlToCompare="txtConfirmPassword"
                    ControlToValidate="txtPassword" SetFocusOnError="True"></asp:CompareValidator>
            </td></tr>
        <tr><td>
            <asp:Label ID="Label3" runat="server" Text="Confirm Password"></asp:Label>
            </td><td>
                <asp:TextBox ID="txtConfirmPassword" runat="server"></asp:TextBox>
                <asp:CompareValidator ID="CompareValidator2"
                     runat="server" ControlToCompare="txtPassword"
                    ControlToValidate="txtConfirmPassword"
                    ErrorMessage="Password Not Same" SetFocusOnError="True"></asp:CompareValidator>
            </td></tr>
        <tr><td>
            <asp:Label ID="Label4" runat="server" Text="Country"></asp:Label>
            </td><td>
                <asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>
                <asp:RequiredFieldValidator ID="RequiredFieldValidator1"
                    runat="server" ControlToValidate="TextBox1"
                    ErrorMessage="Fill Country Name" SetFocusOnError="True"></asp:RequiredFieldValidator>
            </td></tr>
        <tr><td colspan="2">
            <asp:Button ID="Button1" runat="server" Text="Save" />
            </td></tr>


    </table>
    </div>
        <asp:ValidationSummary ID="ValidationSummary1" runat="server" />
    </form>
</body>

</html>






                
           




                                                                     









0 comments:

Post a Comment