The Login.aspx page (C#) : Login « Login Security « ASP.Net






The Login.aspx page (C#)

 

<%@ Page Language="C#"%>
    
<script runat="server">
      protected void Button1_Click(object sender, EventArgs e)
    {
        if (TextBox1.Text == "A" && TextBox2.Text == "B") {
            FormsAuthentication.RedirectFromLoginPage(TextBox1.Text, true);
        }
        else {
            Response.Write("Invalid credentials");
        }
    }
</script>

    
<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
    <title>Login Page</title>
</head>
<body>
    <form id="form1" runat="server">
    <div>
        Username<br />
        <asp:TextBox ID="TextBox1" runat="server"></asp:TextBox><br />
        <br />
        Password<br />
        <asp:TextBox ID="TextBox2" runat="server"
         TextMode="Password"></asp:TextBox><br />
        <br />
        <asp:Button ID="Button1" OnClick="Button1_Click" runat="server"
         Text="Submit" />
    </div>
    </form>
</body>
</html>

 








Related examples in the same category

1.Providing a login for the end user using the Login control
2.A formatted Login control
3.The Login.aspx page (VB)
4.Windows Security
5.Forms Security Setup