Code for Login Page
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Login.aspx.cs" Inherits="gati_test.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 id="Head1" runat="server">
<title>Login</title>
<style type="text/css">
.design
{
text-align: right;
font-family: 'Segoe UI';
font-size: 12px;
}
.design a
{
color: #0787b6;
}
.style1
{
width: 145px;
}
.round
{
-moz-border-radius: 20px;
-webkit-border-radius: 20px;
-khtml-border-radius: 20px;
border-radius: 20px;
}
.style2
{
color: #000000;
}
.style3
{
color: #003399;
font-weight: bold;
}
</style>
<link href="~/Styles/Site.css" rel="stylesheet" type="text/css" />
</head>
<body>
<form id="form1" runat="server">
<div class="page">
<div class="header_login">
<%--<div class="title" style="margin-top: 60px;">
<a href="Default.aspx">
<img src="images/yt_logo.png" /></a>
</div>--%>
<br />
<br /><br />
</div>
<div>
<%-- <img src="images/login_form.jpg" />--%>
<br /><br /><br /><br />
<center>
<fieldset class="round" style="width:400px; height:240px; background-color:#4682B4">
<center>
<asp:Label ID="lbl" runat="server" Text="Login"
style="font-weight: 700; color: #FFFFFF; font-size: x-large"></asp:Label>
<table cellpadding="5px"
style="margin-top: 19px; margin-left:0px; height: 170px; width: 100%;">
<tr>
<td style="text-align:center">
<asp:Label ID="lbl_name" runat="server" Text="User Name :" CssClass="loginlable"
ForeColor="Black"></asp:Label>
</td>
<td >
<asp:TextBox ID="txt_name" runat="server" CssClass="logininput"></asp:TextBox>
<asp:RequiredFieldValidator ID="RequiredFieldValidator1" runat="server" ErrorMessage="Required"
ValidationGroup="v" ControlToValidate="txt_name" style="color: #FF0000"></asp:RequiredFieldValidator>
</td>
</tr>
<tr>
<td style="text-align:center">
<asp:Label ID="lbl_password" runat="server" Text="Password :"
CssClass="loginlable" ForeColor="Black"></asp:Label>
</td>
<td>
<asp:TextBox ID="txt_password" runat="server" TextMode="Password" CssClass="logininput"></asp:TextBox>
<asp:RequiredFieldValidator ID="RequiredFieldValidator4" runat="server" ErrorMessage="Required"
ValidationGroup="v" ControlToValidate="txt_password"
style="color: #FF0000"></asp:RequiredFieldValidator>
</td>
</tr>
<tr>
<td class="style1">
</td>
<td>
<asp:ImageButton ID="ImageButton1" runat="server" ValidationGroup="v"
ImageUrl="~/images/login_button.png" Height="36px"
onclick="ImageButton1_Click" />
<asp:ImageButton ID="Imgbtn_signup" runat="server"
ImageUrl="~/images/signup-button-i6.png" Height="38px"
onclick="Imgbtn_signup_Click" />
</td>
</tr>
<tr>
<td class="style1">
</td>
<td align="left">
<asp:Label ID="lblerror" runat="server" style="color:red" Text="Label"></asp:Label>
</td>
</tr>
</table>
</center>
</fieldset>
</center>
</div>
<%-- <div class="contant_sinup">
</div>--%>
<br /><br />
<div class="clear">
<span class="style2">Design and Developed by </span>
<a href="http://www.online24x7.in/" target="_blank" class="style3">Online24x7</a></div>
</div>
</form>
</body>
</html>
.cs code
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;
using System.Data.SqlClient;
namespace gati_test
{
public partial class Login : System.Web.UI.Page
{
CS_registration _Lgn = new CS_registration();
protected void Page_Load(object sender, EventArgs e)
{
if(!IsPostBack)
lblerror.Visible = false;
}
protected void ImageButton1_Click(object sender, ImageClickEventArgs e)
{
if (txt_name.Text.Trim().Length > 0 && txt_password.Text.Trim().Length > 0)
{
_Lgn.UserId = txt_name.Text.Trim();
_Lgn.Password = txt_password.Text.Trim();
DataSet ds = new DataSet();
DataTable dt = new DataTable();
dt = _Lgn.Login();
if (dt!=null && dt.Rows.Count>0)
{
Session["username"] = dt.Rows[0]["username"].ToString();
Session["empid"] = dt.Rows[0]["EmpId"].ToString();
Response.Redirect("Default.aspx");
}
else
{
lblerror.Visible = true;
lblerror.Text = "Login failed for user : " + txt_name.Text;
}
clear();
}
}
void clear()
{
txt_name.Text = txt_password.Text = string.Empty;
}
protected void Imgbtn_signup_Click(object sender, ImageClickEventArgs e)
{
if (Imgbtn_signup != null)
{
Response.Redirect("UserRegistration.aspx");
}
}
}
}
<!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 id="Head1" runat="server">
<title>Login</title>
<style type="text/css">
.design
{
text-align: right;
font-family: 'Segoe UI';
font-size: 12px;
}
.design a
{
color: #0787b6;
}
.style1
{
width: 145px;
}
.round
{
-moz-border-radius: 20px;
-webkit-border-radius: 20px;
-khtml-border-radius: 20px;
border-radius: 20px;
}
.style2
{
color: #000000;
}
.style3
{
color: #003399;
font-weight: bold;
}
</style>
<link href="~/Styles/Site.css" rel="stylesheet" type="text/css" />
</head>
<body>
<form id="form1" runat="server">
<div class="page">
<div class="header_login">
<%--<div class="title" style="margin-top: 60px;">
<a href="Default.aspx">
<img src="images/yt_logo.png" /></a>
</div>--%>
<br />
<br /><br />
</div>
<div>
<%-- <img src="images/login_form.jpg" />--%>
<br /><br /><br /><br />
<center>
<fieldset class="round" style="width:400px; height:240px; background-color:#4682B4">
<center>
<asp:Label ID="lbl" runat="server" Text="Login"
style="font-weight: 700; color: #FFFFFF; font-size: x-large"></asp:Label>
<table cellpadding="5px"
style="margin-top: 19px; margin-left:0px; height: 170px; width: 100%;">
<tr>
<td style="text-align:center">
<asp:Label ID="lbl_name" runat="server" Text="User Name :" CssClass="loginlable"
ForeColor="Black"></asp:Label>
</td>
<td >
<asp:TextBox ID="txt_name" runat="server" CssClass="logininput"></asp:TextBox>
<asp:RequiredFieldValidator ID="RequiredFieldValidator1" runat="server" ErrorMessage="Required"
ValidationGroup="v" ControlToValidate="txt_name" style="color: #FF0000"></asp:RequiredFieldValidator>
</td>
</tr>
<tr>
<td style="text-align:center">
<asp:Label ID="lbl_password" runat="server" Text="Password :"
CssClass="loginlable" ForeColor="Black"></asp:Label>
</td>
<td>
<asp:TextBox ID="txt_password" runat="server" TextMode="Password" CssClass="logininput"></asp:TextBox>
<asp:RequiredFieldValidator ID="RequiredFieldValidator4" runat="server" ErrorMessage="Required"
ValidationGroup="v" ControlToValidate="txt_password"
style="color: #FF0000"></asp:RequiredFieldValidator>
</td>
</tr>
<tr>
<td class="style1">
</td>
<td>
<asp:ImageButton ID="ImageButton1" runat="server" ValidationGroup="v"
ImageUrl="~/images/login_button.png" Height="36px"
onclick="ImageButton1_Click" />
<asp:ImageButton ID="Imgbtn_signup" runat="server"
ImageUrl="~/images/signup-button-i6.png" Height="38px"
onclick="Imgbtn_signup_Click" />
</td>
</tr>
<tr>
<td class="style1">
</td>
<td align="left">
<asp:Label ID="lblerror" runat="server" style="color:red" Text="Label"></asp:Label>
</td>
</tr>
</table>
</center>
</fieldset>
</center>
</div>
<%-- <div class="contant_sinup">
</div>--%>
<br /><br />
<div class="clear">
<span class="style2">Design and Developed by </span>
<a href="http://www.online24x7.in/" target="_blank" class="style3">Online24x7</a></div>
</div>
</form>
</body>
</html>
.cs code
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;
using System.Data.SqlClient;
namespace gati_test
{
public partial class Login : System.Web.UI.Page
{
CS_registration _Lgn = new CS_registration();
protected void Page_Load(object sender, EventArgs e)
{
if(!IsPostBack)
lblerror.Visible = false;
}
protected void ImageButton1_Click(object sender, ImageClickEventArgs e)
{
if (txt_name.Text.Trim().Length > 0 && txt_password.Text.Trim().Length > 0)
{
_Lgn.UserId = txt_name.Text.Trim();
_Lgn.Password = txt_password.Text.Trim();
DataSet ds = new DataSet();
DataTable dt = new DataTable();
dt = _Lgn.Login();
if (dt!=null && dt.Rows.Count>0)
{
Session["username"] = dt.Rows[0]["username"].ToString();
Session["empid"] = dt.Rows[0]["EmpId"].ToString();
Response.Redirect("Default.aspx");
}
else
{
lblerror.Visible = true;
lblerror.Text = "Login failed for user : " + txt_name.Text;
}
clear();
}
}
void clear()
{
txt_name.Text = txt_password.Text = string.Empty;
}
protected void Imgbtn_signup_Click(object sender, ImageClickEventArgs e)
{
if (Imgbtn_signup != null)
{
Response.Redirect("UserRegistration.aspx");
}
}
}
}
No comments:
Post a Comment