Login Page Using Standard Control Tools From .NET Framework 4.0
Login.aspx
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="LOGIN.aspx.cs" Inherits="using_standard_control.LOGIN" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
</head>
<body>
<form id="form1" runat="server">
<div align=center>
<h1><font color=navy> Login page </font></h1></div>
<hr>
<br>
<br>
<%-- //////////////////////////Username text box////////////////////--%>
<p align=center>
<font color=maroon> UserName
<asp:TextBox ID="txt_username" runat="server" Width="268px" BackColor="#BFD5D5"
Height="29px" ontextchanged="txt_username_TextChanged"></asp:TextBox>
<asp:RequiredFieldValidator ID="RequiredFieldValidator1" runat="server"
ErrorMessage="Enter Valid Username" ControlToValidate="txt_username"></asp:RequiredFieldValidator>
</font>
</p>
<%--//////////////////////////////Password text box ///////////////////--%>
<p align=center>
<font color=maroon>Password <asp:TextBox
ID="txt_password" runat="server" Width="267px" BackColor="#BFD5D5"
Height="32px" TextMode="Password" ontextchanged="txt_password_TextChanged"></asp:TextBox>
<asp:RequiredFieldValidator ID="RequiredFieldValidator2" runat="server"
ErrorMessage="Wrong Password" ControlToValidate="txt_password"></asp:RequiredFieldValidator>
</font>
</p>
<%--///////////////login button/////////////--%>
<p align=center>
<asp:Button ID="btn_login" runat="server" BackColor="White" BorderColor="Red"
BorderStyle="Solid" ForeColor="#AA600D" Text="Login" Width="158px"
Height="45px" onclick="btn_login_Click" />
</p>
</form>
</body>
</html>
Login.aspx.cs
In the .aspx.cs file we write the business logic for any webpage.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
namespace using_standard_control
{
public partial class LOGIN : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
}
protected void txt_username_TextChanged(object sender, EventArgs e)
{
}
protected void txt_password_TextChanged(object sender, EventArgs e)
{
}
protected void btn_login_Click(object sender, EventArgs e)
{
if (txt_username.Text.Equals("Compulink") && txt_password.Text.Equals("12345"))
{
Response.Redirect("REGISTER.aspx");
}
else {
Response.Write("ERROR while login");
}
}
}
}

No comments:
Post a Comment