aspx:
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="pgLogin.aspx.cs" Inherits="Login" Title="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>Login</title>
<style type="text/css">
.style1 {
width: 1195px;
height: 125px;
}
.style2
{
height: 125px;
}
</style>
</head>
<body style="background-color: #FFFFFF">
<form id="form1" runat="server" >
<div >
<table style="height: 354px">
<tr>
<td class="style2">
</td>
<td class="style1">
</td>
</tr>
<tr>
<td colspan ="2" align="center" >
<asp:Login ID="LoginGateway" runat="server" BackColor="#EFF3FB" Height="208px"
Width="389px" style="margin-top: 0px" onloggingin="LoginGateway_LoggingIn"
BorderColor="#B5C7DE" BorderPadding="4" BorderStyle="Solid" BorderWidth="1px"
Font-Names="Microsoft Sans Serif" Font-Size="Small" ForeColor="#333333"
>
<TextBoxStyle Font-Size="Small" />
<LoginButtonStyle BackColor="White" BorderColor="#507CD1" BorderStyle="Solid"
BorderWidth="1px" Font-Names="Microsoft Sans Serif" Font-Size="Small"
ForeColor="#284E98" />
<InstructionTextStyle Font-Italic="True" ForeColor="Black" />
<TitleTextStyle BackColor="#507CD1" Font-Bold="True" Font-Size="Small"
ForeColor="White" />
</asp:Login>
</td>
</tr>
</table>
</div>
</form>
</body>
</html>
aspx.cs:
public partial class Login : System.Web.UI.Page
{
SqlDataReader reader;
string strPass = null;
string strConnectionString = null;
DataAccessLayer layer;
protected void Page_Init(object sender, EventArgs e)
{
strConnectionString = WebConfigurationManager.ConnectionStrings["Gateway"].ConnectionString;
layer = new DataAccessLayer(strConnectionString);
}
protected void Page_Load(object sender, EventArgs e)
{
if (Request.UserAgent.IndexOf("AppleWebKit") > 0)
{
Request.Browser.Adapters.Clear();
}
}
protected void LoginGateway_LoggingIn(object sender, LoginCancelEventArgs e)
{
string strName = LoginGateway.UserName;
string strPassword = LoginGateway.Password;
string strQuery = "Select Password from Login where [User]='"+ strName+"'" ;
layer.Open();
object objResult = layer.ExecuteScalar(strQuery);
strPass = objResult.ToString();
layer.Close();
strQuery = null;
if (strPass == strPassword)
{
Session["UserName"] = strName;
Session["Password"] = strPass;
Response.Redirect("~/Main.aspx");
}
}
}
Thank you!
plz help me!