📄 defaultlogin.aspx.cs
字号:
using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Data.SqlClient;
//该源码下载自www.51aspx.com(51aspx.com)
public partial class defaultlogin : System.Web.UI.Page
{
BaseClass bc = new BaseClass();
protected void Page_Load(object sender, EventArgs e)
{
if (Session["code"] == null)
{
panel1.Visible = true;
panel2.Visible = false;
}
else
{
if (Session["Name"] != "")
{
Label1.Text = Session["Name"].ToString();
Label1.Visible = true;
}
panel1.Visible = false;
panel2.Visible = true;
}
}
protected void btnLogin_Click(object sender, EventArgs e)
{
string imagecode = Session["checkCode"].ToString().ToLower();//取得验证码
string username = txtUserName.Text.Trim().ToString();
string password = txtPassword.Text.Trim().ToString();;
string checkcode = txtcheckcode.Text.Trim().ToLower() ;
if (checkcode !=imagecode)
{
Response.Write("<script>alert('验证码错误');history.back()</script>");
return;
}
string sqlstr = "select * from homeHold where uid='" + username + "' and password='" + password + "'";
SqlDataReader mydr = bc.ExecRead(sqlstr);
if (mydr.Read())
{
//Response.Write(mydr["ownerID"].ToString());
//Response.End();
Session["code"] = mydr["code"].ToString();
Session["Name"] = mydr["Name"].ToString();
panel1.Visible = false;
panel2.Visible = true;
}
else
{
Response.Write("<br/><font size='2'> 用户名或密码错误,<a href='defaultlogin.aspx'>返回</a></font>");
Response.End();
}
bc.Closeconn();
}
protected void LinkButton1_Click(object sender, EventArgs e)
{
Session["code"] = "";
Response.Redirect("defaultlogin.aspx");
}
protected void Button1_Click(object sender, EventArgs e)
{
Session.Remove("code");
Response.Redirect("defaultlogin.aspx");
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -