<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Loginn.aspx.cs" Inherits="todayTest.Loginn" %>
<!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>
<style type="text/css">
.style1
{
width: 100%;
}
</style>
</head>
<body>
<form id="form1" runat="server">
<table class="style1">
<tr>
<td colspan="2">
<h1 align="center">Admin Login</h1></td>
</tr>
<tr>
<td>
</td>
<td>
</td>
</tr>
<tr>
<td>
<asp:Label ID="Label1" runat="server" Text="Username"></asp:Label>
</td>
<td>
<asp:TextBox ID="txtusername" runat="server"></asp:TextBox>
<asp:RequiredFieldValidator ID="RequiredFieldValidator1" runat="server"
ErrorMessage="*" ControlToValidate="txtusername"></asp:RequiredFieldValidator>
</td>
</tr>
<tr>
<td>
<asp:Label ID="Label2" runat="server" Text="Password"></asp:Label>
</td>
<td>
<asp:TextBox ID="txtpassword" runat="server" ></asp:TextBox>
<asp:RequiredFieldValidator ID="RequiredFieldValidator2" runat="server"
ErrorMessage="*" ControlToValidate="txtpassword"></asp:RequiredFieldValidator>
</td>
</tr>
<tr>
<td>
</td>
<td>
</td>
</tr>
<tr>
<td>
</td>
<td>
<asp:Button ID="BtnLogin" runat="server" Text="Login"
onclick="BtnLogin_Click" />
<asp:Label ID="lbllog" runat="server" Text=""></asp:Label>
</td>
</tr>
</table>
<div>
</div>
</form>
</body>
</html>
<!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>
<style type="text/css">
.style1
{
width: 100%;
}
</style>
</head>
<body>
<form id="form1" runat="server">
<table class="style1">
<tr>
<td colspan="2">
<h1 align="center">Admin Login</h1></td>
</tr>
<tr>
<td>
</td>
<td>
</td>
</tr>
<tr>
<td>
<asp:Label ID="Label1" runat="server" Text="Username"></asp:Label>
</td>
<td>
<asp:TextBox ID="txtusername" runat="server"></asp:TextBox>
<asp:RequiredFieldValidator ID="RequiredFieldValidator1" runat="server"
ErrorMessage="*" ControlToValidate="txtusername"></asp:RequiredFieldValidator>
</td>
</tr>
<tr>
<td>
<asp:Label ID="Label2" runat="server" Text="Password"></asp:Label>
</td>
<td>
<asp:TextBox ID="txtpassword" runat="server" ></asp:TextBox>
<asp:RequiredFieldValidator ID="RequiredFieldValidator2" runat="server"
ErrorMessage="*" ControlToValidate="txtpassword"></asp:RequiredFieldValidator>
</td>
</tr>
<tr>
<td>
</td>
<td>
</td>
</tr>
<tr>
<td>
</td>
<td>
<asp:Button ID="BtnLogin" runat="server" Text="Login"
onclick="BtnLogin_Click" />
<asp:Label ID="lbllog" runat="server" Text=""></asp:Label>
</td>
</tr>
</table>
<div>
</div>
</form>
</body>
</html>
-----------web.aspx--------------
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using Be_test;
using Bl_Test;
namespace todayTest
{
public partial class Loginn : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
HttpCookie lp=Request.Cookies["mod"];
if (lp != null)
{
Response.Redirect("papu.aspx");
}
}
}
protected void BtnLogin_Click(object sender, EventArgs e)
{
BEtest be = new BEtest();
be.Name = txtusername.Text;
be.address = txtpassword.Text;
var b = new BLtest().show().Where(id => id.Name.ToUpper() == txtusername.Text.ToUpper() && id.address.ToUpper() == txtpassword.Text.ToUpper());
if (b.Count() != 0)
{
createcookies(be);
Response.Redirect("papu.aspx");
}
else
{
lbllog.Text = "Wrong Username Or Password";
}
}
public void createcookies(BEtest bes)
{
HttpCookie cook = new HttpCookie("mod");
cook["Name"] = txtusername.Text;
cook["address"] = txtpassword.Text;
Response.SetCookie(cook);
}
}
}
No comments :
Post a Comment