How to Create a Simple Login Form in ASP.NET using Visual Studio 2022? [With source Code]
designing code:
<head runat="server"> <title>Login Form</title> </head> <body> <h1 align="center">Login Form</h1> <form id="form1" runat="server"> <table align="center"> <tr> <td>Username</td> <td> <asp:TextBox ID="txtUser" runat="server"></asp:TextBox></td> </tr> <tr> <td>Password</td> <td> <asp:TextBox ID="txtPass" runat="server" TextMode="Password"></asp:TextBox></td> </tr> <tr> <td></td> <td> <asp:Button ID="Button1" runat="server" Text="Login" OnClick="Button1_Click" /></td> </tr> </table> </form> </body>
backend code: [inside the clicking event of login button]
String username = txtUser.Text; String password = txtPass.Text; if(username=="admin" && password == "admin") { Response.Write("<script type='text/javascript'>alert('Login Successful')</script>"); } else { Response.Write("<script type='text/javascript'>alert('Login Error')</script>"); }