?? login.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;
public partial class Manage_login : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
Random rnd = new Random();
this.Label1.Text = rnd.Next(0, 9).ToString() + rnd.Next(0, 9).ToString() + rnd.Next(0, 9).ToString() + rnd.Next(0, 9).ToString();
}
}
protected void ImageButton1_Click(object sender, ImageClickEventArgs e)
{
if (Page.IsValid == true)
{
if (this.number.Text != this.Label1.Text)
{
Response.Write(this.number.Text +this.Label1.Text);
Response.Write("<script lanuage=javascript>alert('驗(yàn)證碼錯誤');location='javascript:history.go(-1)'</script>");
}
else
{
SqlConnection strcon = new SqlConnection(System.Configuration.ConfigurationManager.AppSettings["strcon"]);
strcon.Open();
SqlCommand scd = new SqlCommand("select count(*) from tb_Admin where username='" + this.username.Text.ToString() + "' and userpwd='" + this.userpwd.Text.ToString() + "'", strcon);
int count = Convert.ToInt32(scd.ExecuteScalar());
if (count > 0)
{
Session["adminname"] = this.username.Text.ToString();
Session["username"] = this.username.Text.ToString();
Response.Redirect("index.aspx");
}
else
{
Response.Write("<script language=javascript>alert('您輸入的用戶名或者密碼有誤');location='javascript:history.go(-1)'</script>");
}
}
}
}
protected void CustomValidator1_ServerValidate(object source, ServerValidateEventArgs args)
{
string username1 = this.username.Text.ToString();
for (int i = 0; i < (int)username1.Length; i++)
{
string name = username1.Substring(i, 1);
if (name == "'" || name == "%" || name == "<" || name == ">" || name == "&" || name == "|")
{
args.IsValid = false;
}
else
{
args.IsValid = true;
}
}
}
protected void CustomValidator2_ServerValidate(object source, ServerValidateEventArgs args)
{
string userpwd1 = this.userpwd.Text.ToString();
for (int i = 0; i < (int)userpwd1.Length; i++)
{
string pwd = userpwd1.Substring(i, 1);
if (pwd == "'" || pwd == "%" || pwd == "<" || pwd == ">" || pwd == "&" || pwd == "|")
{
args.IsValid = false;
}
else
{
args.IsValid = true;
}
}
}
}
?? 快捷鍵說明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -