Create Simple Static Login Form in ASP.Net

Create sipmle Login form with TextBox control

Create Simple Static Login Form in ASP.Net

- Here, In this post we will learn to make simple static Login Form.

- First we decided Login UserName and Login Password and check them on Button Click Event.

- Here our Login UserName = meera and Password = academy

Write Below code in Body tag :-

<body>
    <form id=”form1″ runat=”server”>
<table style=”width: 440px”>
                        <tr>
                            <td style=”width: 108px”>
                                Enter Username :</td>
                            <td style=”width: 79px”>
                                <asp:TextBox ID=”txtusername” runat=”server”></asp:TextBox></td>
                            <td style=”width: 100px; text-align: left”>
                                <asp:Label ID=”lbluname” runat=”server” ForeColor=”Red”></asp:Label></td>
                        </tr>
                        <tr>
                            <td style=”width: 108px; height: 26px”>
                                Enate Password :</td>
                            <td style=”width: 79px; height: 26px”>
                                <asp:TextBox ID=”txtpassword” runat=”server”></asp:TextBox></td>
                            <td style=”width: 100px; height: 26px; text-align: left”>
                                <asp:Label ID=”lblupass” runat=”server” ForeColor=”Red”></asp:Label></td>
                        </tr>
                        <tr>
                            <td style=”width: 108px; height: 21px”>
                            </td>
                            <td style=”width: 79px; height: 21px”>
                                &nbsp;<asp:Button ID=”btnlogin” runat=”server” Font-Bold=”True” Height=”32px” OnClick=”btnlogin_Click”
                                    Text=”Login” Width=”64px” /></td>
                            <td style=”width: 100px; height: 21px”>
                            </td>
                        </tr>
                        <tr>
                            <td style=”width: 108px; height: 21px”>
                            </td>
                            <td colspan=”2″ style=”height: 21px; text-align: left”>
                                <asp:Label ID=”lbllogin” runat=”server” Font-Bold=”True”></asp:Label></td>
                        </tr>
                    </table>
</form>
</body>

Login Form with TextBox Control in ASP.Net

Login Form with TextBox Control in ASP.Net

Write below code on Button Click Event:-

protected void btnlogin_Click(object sender, EventArgs e)
    {
        lbluname.Text = “”;
        lblupass.Text = “”;
        if (txtusername.Text == “”)
        {
            lbluname.Text = “Enter uname”;
        }
        else if (txtpassword.Text == “”)
        {
            lblupass.Text = “Enter Password”;
        }
        else
        {
            if (txtusername.Text == “meera” && txtpassword.Text == “academy”)
            {
                lbllogin.Text = “Login Successfull !!”;
                txtusername.Text = “”;
                txtpassword.Text = “”;
            }
            else
            {
                lbllogin.Text = “Invalid USername/Password !!”;
            }
        }
    }

Login Form with TextBox Control in ASP.Net

Login Form with TextBox Control in ASP.Net

 

Login Form with TextBox Control in ASP.Net

Login Form with TextBox Control in ASP.Net

Leave a Reply

Your email address will not be published. Required fields are marked *

7 + 8 =


You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code class="" title="" data-url=""> <del datetime=""> <em> <i> <q cite=""> <strike> <strong> <pre class="" title="" data-url=""> <span class="" title="" data-url="">