⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 login.aspx.cs

📁 留言板文件说明太短 文件说明太短 文件说明太短 文件说明太短 文件说明太短 文件说明太短 文件说明太短
💻 CS
字号:
using System.Data.OleDb;
using System;
using System.Collections;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Web;
using System.Web.SessionState;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.HtmlControls;
using System.Configuration;

namespace book
{
	/// <summary>
	/// Longin 的摘要说明。
	/// </summary>
	public class Longin : System.Web.UI.Page
	{
		protected OleDbConnection myconn=new OleDbConnection();
		protected System.Web.UI.WebControls.TextBox TextBox1;
		protected System.Web.UI.WebControls.TextBox TextBox3;
		protected System.Web.UI.WebControls.ImageButton ImageButton1;
		protected System.Web.UI.WebControls.TextBox TextBox2;
	
		private void Page_Load(object sender, System.EventArgs e)
		{
			// 在此处放置用户代码以初始化页面
			string VNum = "";
			if (Session["CheckCode"]!=null)
			{
				VNum=Session["CheckCode"].ToString(); 

				ViewState["VNum"]=VNum;
				Session["CheckCode"]=null;

			}
		}

		#region Web 窗体设计器生成的代码
		override protected void OnInit(EventArgs e)
		{
			//
			// CODEGEN: 该调用是 ASP.NET Web 窗体设计器所必需的。
			//
			InitializeComponent();
			base.OnInit(e);
		}
		
		/// <summary>
		/// 设计器支持所需的方法 - 不要使用代码编辑器修改
		/// 此方法的内容。
		/// </summary>
		private void InitializeComponent()
		{    
			this.ImageButton1.Click += new System.Web.UI.ImageClickEventHandler(this.ImageButton1_Click);
			this.Load += new System.EventHandler(this.Page_Load);

		}
		#endregion

		private void ImageButton1_Click(object sender, System.Web.UI.ImageClickEventArgs e)
		{
			    myconn.ConnectionString="Provider=Microsoft.Jet.OleDb.4.0;"+"Data Source="+Server.MapPath("book/book.mdb");
				myconn.Open();
				string adminsql="select * from adminbook where admin8='"+TextBox1.Text.Replace("'","''")+"' and pass8='"+TextBox2.Text.Replace("'","''")+"' ";
			    OleDbCommand Comm=new OleDbCommand(adminsql,myconn);
			    OleDbDataReader dr=Comm.ExecuteReader();
			if (dr.Read())
				if (Request["TextBox3"]==ViewState["VNum"].ToString())
				{
					Session["admin"]=TextBox1;
					Session["pass"]=TextBox2;
					Response.Redirect("index.aspx");
				}	
				else
				{
					TextBox1.Text="";
					TextBox2.Text="";
					Response.Write("<script>alert('验证码错误')</script>");
				}
			else
			{
				TextBox1.Text="";
				TextBox2.Text="";
				Response.Write("<script>alert('管理员名称或密码错误')</script>");
			}
		{
			dr.Close();
			myconn.Close();
		}
		}
	}
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -