Required Field Validator Control in asp.net

 For Example: Write a program to demonstrate the use of Required Field Validator. 

<html>

<head runat="server">

    <title>Aryn Computers(Required Field Validator) </title>

</head>

<body>

    <form id="form1" runat="server">

    <div>

    <center> 

<asp:Label ID="Label1" runat="server" Text="Web Page Loging Page" Font-Bold="True" 

   Font-Size="X-Large" Font-Underline="True"></asp:Label>  </center>

  

    </div>

    <asp:Label ID="Label2" runat="server" Text="ID: "></asp:Label>

    <asp:TextBox ID="TextBox1" runat="server" Width="237px"></asp:TextBox>

    <asp:Label ID="Label4" runat="server" ForeColor="Red" Text="*"></asp:Label>

    <asp:RequiredFieldValidator ID="RequiredFieldValidator1" runat="server" 

    ControlToValidate="TextBox1"  ErrorMessage="Please enter user Id..." ForeColor="Red"></asp:RequiredFieldValidator> 

    <asp:Label ID="Label3" runat="server" Text="Password: "></asp:Label>

    <asp:TextBox ID="TextBox2" runat="server" Width="231px"></asp:TextBox>

    <asp:Label ID="Label5" runat="server" ForeColor="Red" Text="*"></asp:Label>

    <asp:RequiredFieldValidator ID="RequiredFieldValidator2" runat="server" ControlToValidate  = "TextBox2" ForeColor="Red"

        ErrorMessage=" PLZ enter Password"></asp:RequiredFieldValidator> 

    <div style="margin-left: 280px">

        <asp:Button ID="Button1" runat="server" Text="Login" Font-Bold="True" 

            Width="90px" />

    </div>

    <br />

    </form>

</body>

</html>

Output: 




Comments

Popular posts from this blog

simple program C#

Regular Expression Validator Control in asp.net

two dimension array in C#