Create a Login page - ASP.NET Program

Create an ASP.NET Login page similar to the image given below. login page

Store the User ID and password in variables. After matching the entered credentials, user should get navigated to the welcome.aspx page with message “Welcome Mr./Mrs____”.


Here, we create a ASP.NET login page which can accept username and password from the user and validate it.

If username and password match, the login page redirects to welcome.aspx page and displays the welcome message, else it throws an error message.

The username and password are stored in the local variable in page. We will use the VB language to develop this application.


<!DOCTYPE html>
<html xmlns="">
   <head runat="server">
       <script language="VB" runat="server">
             Private Sub Page_Load(sender As Object, e As EventArgs)
                If Request.RequestType = "POST" Then
                    Dim userid As String = Request.Form("txtUserid")
                    Dim password As String = Request.Form("txtpwd")

                    If userid = "matrix" And password = "12345" Then
                        lblStatus.Text = "Invalid userid or password!"
                    End If

                End If
            End Sub

    <form id="f1" method="post" runat="server">
            <fieldset style="width:280px; background-color:aqua">
                              <td>User ID:<font color="#cc0000">*</font></td>
                              <td><asp:TextBox ID="txtUserid" runat="server"></asp:TextBox><br /> </td>
                              <td>Password:<font color="#cc0000">*</font></td>
                              <td><asp:TextBox ID="txtPwd" runat="server" TextMode="Password"></asp:TextBox><br /></td>
                             <td> </td>
                             <td><asp:Button ID="btnLogin" runat="server" Text="Login" /></td>
                             <td> </td>
                             <td><asp:Label ID="lblStatus" runat="server" Text=""></asp:Label></td>


Login Screen login page

Wrong userid or password

wrong userid password

Correct userid and password (welcome page)

welcome msg