62,046
社区成员
发帖
与我相关
我的任务
分享
public string MessageBox(string txt,string Url)
{
string str;
str = "<script language=javascript>alert('"+txt+"');location='"+Url+"'</script>";
return str;
}
protected void Button1_Click(object sender, EventArgs e)
{
if (i == 1)
{
if(bc.seleSQL("select count(*) from Usersmr where UserName='"+UserName.Text+"' AND UserPwd='"+UserPwd.Text+"'AND Roled='"+qx+"'"))
{
Session["loginName"] = UserName.Text;
Response.Write(bc.MessageBox("学生登陆成功","../student/Text.aspx"));
}
else
{
Response.Write(bc.MessageBox("登录失败,请输入正确的用户名或者密码","Login.aspx"));
}
}
if(i==0)
{
if(bc.seleSQL("select count(*) from Usersmr where UserName='"+UserName.Text+"' AND UserPwd='"+UserPwd.Text+"'AND Roled='"+qxa+"'"))
{
Session["loginName"] = UserName.Text;
Response.Write(bc.MessageBox("教师登陆成功","../teacher/teacher.aspx"));
}
else
{
Response.Write(bc.MessageBox("登录失败,请输入正确的用户名或者密码","Login.aspx"));
}
}
}
using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
public partial class teacher_teacher : System.Web.UI.Page
{
string a, b;
protected void Page_Load(object sender, EventArgs e)
{
try
{
a = Session["loginName"].ToString();
//Label1.Text = a;
DataBase bc = new DataBase();
Response.Write(bc.MessageBox(a));
//bc.createCon();
//b=bc.getRead("select DepartmentId from Usersmr where UserName='"+a+"'");
//Label2.Text = b;
}
catch (Exception z) { }
}
protected void Button1_Click(object sender, EventArgs e)
{
}
}
Session["loginName"] = UserName.Text;
string a = Session["loginName"].ToString();
string b =bc.getRead("select DepartmentId from Usersmr where UserName='"+a+"'");
Response.Write(bc.MessageBox(a+b+"教师登陆成功","../teacher/teacher.aspx"));
[Quote=引用 9 楼 的回复:]
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)//不加这句 那么首次加载Session是空的 因为 还没有传过来
{
try
{
a = Session["loginName"].ToString();
//Label1.Text = a;
DataBase bc = new DataBase();
Response.Write(bc.MessageBox(a));
//bc.createCon();
//b=bc.getRead("select DepartmentId from Usersmr where UserName='"+a+"'");
//Label2.Text = b;
}
catch (Exception z) { }
}
}