Overview:
in this article explain about how to create login page without sql database in asp.net, login verified then success the login user redirect to another page.
Step 1:
source code:
<asp:Label ID="Label4" runat="server" Font-Bold="True"
Font-Names="Monotype Corsiva" Font-Size="X-Large" Text="Admin Login"></asp:Label>
</p>
<p>
</p>
<p>
<asp:Label ID="Label2" runat="server" Text="UserId"></asp:Label>
<asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>
</p>
<p>
<asp:Label ID="Label3" runat="server" Text="Password"></asp:Label>
<asp:TextBox ID="TextBox2" runat="server" TextMode="Password"></asp:TextBox>
</p>
<p>
<asp:Button ID="Button1" runat="server" Height="32px" Text="Login"
Width="94px" onclick="Button1_Click" />
<asp:Button ID="Button2" runat="server" Height="30px" Text="Reset"
Width="87px" onclick="Button2_Click" />
Source code design:
step-2 : double click login button write the following code
Login Code:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
public partial class Adminlogin : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
}
protected void Button1_Click(object sender, EventArgs e)
{
if (TextBox1.Text == "admin" && TextBox2.Text == "admin")
{
Response.Redirect("Adminhome.aspx");
}
else
{
Response.Write("<script>alert('Invalid Loginid and Password..!')</script>");
}
}
protected void Button2_Click(object sender, EventArgs e)
{
TextBox1.Text = "";
TextBox2.Text = "";
}
}
step -3 : Invalid login
step-4: Success Login then redirect another page
No comments:
Post a Comment