📄 login.ascx.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;
public partial class login : System.Web.UI.UserControl
{
//这里不用asp.net的画图功能产生的随机数~
protected void Page_Load(object sender, EventArgs e)
{
if (!this.Page.IsPostBack)
{
rnd();
}
if (Session["shop"] != null)
{
this.Panel1.Visible = false;
this.Panel2.Visible = true;
}
else
{
this.Panel2.Visible = false;
this.Panel1.Visible = true;
}
}
public void rnd()
{
Random rnd = new Random();
int rndi = 1000 + rnd.Next(8999);
this.Label1.Text = rndi.ToString();
Session["rnd"] = rndi;
}
protected void LinkButton1_Click(object sender, EventArgs e)
{
if (this.TextBox3.Text != Session["rnd"].ToString())
{
Response.Redirect("Default.aspx");
}
else
{
string username = this.TextBox1.Text;
string userpwd = this.TextBox2.Text;
int count = Convert.ToInt32(db.scr("select count(*) from Cs where c1='" + username + "'and c2='" + userpwd + "'"));
if (count > 0)
{
this.Panel1.Visible = false;
this.Panel2.Visible = true;
Session["shop"] = db.scr("select c1 from Cs where c1='" + username + "'");
}
else
{
Response.Write("<script>alert('用户名或密码错误');</script>");
}
}
}
protected void LinkButton2_Click(object sender, EventArgs e)
{
Session.Clear();
Response.Redirect("Default.aspx");
}
protected void LinkButton3_Click(object sender, EventArgs e)
{
if (this.TextBox1.Text == "Admin" && this.TextBox2.Text == "Admin" && this.TextBox3.Text == Session["rnd"].ToString())
Session["Admin"] = this.TextBox1.Text;
Response.Redirect("admin/Default.aspx");
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -