using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using WebApplication1.dao;
using WebApplication1.vo;
namespace WebApplication1.vew
{
public partial class login : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
Session["UserId"] = null;
Session["UserName"] = null;
Session["pass"] = null;
}
} protected void But_insert_Click(object sender, EventArgs e)
{
string _name = this.Text_username.Text.Trim();
string _pass = this.Text_pass.Text.Trim();
if ((_name == "") && (_pass == ""))
{
Response.Write("<script>alert('用户名和密码不能为空!');</script>");
}
else
{
ZhuCe zz = new ZhuCe();
zz.UserName =this.Text_username.Text.Trim();
zz.PassWord =this.Text_pass.Text.Trim();
if (basedao.GetDao().UserLogin(zz.UserName, zz.PassWord))
{
Session["UserId"] = zz.ZId;
Session["UserName"] = zz.UserName;
Session["pass"] = zz.PassWord;
Response.Redirect("selectXin.aspx");
}
else
{
Response.Write("<script>alert('登陆失败,用户名或密码错误');location='login.aspx'</script>");
}
}
} protected void But_cancel_Click(object sender, EventArgs e)
{
this.Text_username.Text = "";
this.Text_pass.Text = "";
}
}
}
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using WebApplication1.dao;
using WebApplication1.vo;
namespace WebApplication1.vew
{
public partial class login : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
Session["UserId"] = null;
Session["UserName"] = null;
Session["pass"] = null;
}
} protected void But_insert_Click(object sender, EventArgs e)
{
string _name = this.Text_username.Text.Trim();
string _pass = this.Text_pass.Text.Trim();
if ((_name == "") && (_pass == ""))
{
Response.Write("<script>alert('用户名和密码不能为空!');</script>");
}
else
{
ZhuCe zz = new ZhuCe();
zz.UserName =this.Text_username.Text.Trim();
zz.PassWord =this.Text_pass.Text.Trim();
if (basedao.GetDao().UserLogin(zz.UserName, zz.PassWord))
{
Session["UserId"] = zz.ZId;
Session["UserName"] = zz.UserName;
Session["pass"] = zz.PassWord;
Response.Redirect("selectXin.aspx");
}
else
{
Response.Write("<script>alert('登陆失败,用户名或密码错误');location='login.aspx'</script>");
}
}
} protected void But_cancel_Click(object sender, EventArgs e)
{
this.Text_username.Text = "";
this.Text_pass.Text = "";
}
}
}
(yynmcao) 等 级:
结帖率:0.00% 你这样做有意义?我直接取到文本框的值跟固定值比较就好了?
string _pass = this.Text_pass.Text.Trim();
把这两个变量 写成你想要的 用户名密码就可以了