用vs2010做了一个用户登录的界面,输入正确的名字跟密码总是弹出登录失败的框
这是login.aspx文件usingSystem;usingSystem.Collections.Generic;usingSystem.Linq;usingSyste...
这是login.aspx文件
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
public partial class login : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
}
protected void Button1_Click(object sender, EventArgs e)
{
string username = TextBox1.Text;
string userpwd = TextBox2.Text;
Response.Redirect("loginsuccess.aspx?name=" + username + "&loginsuccess.aspx?pwd=" + userpwd);
}
protected void Button2_Click(object sender, EventArgs e)
{
TextBox1.Text = " ";
TextBox2.Text = " ";
}
}
这是loginsuccess.aspx文件
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
public partial class loginsuccess : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
if (Request["name"] == "admin" && Request["pwd"] == "123")
{
Response.Write("<br/>" + Request["name"].ToString() + ",欢迎你进入校园在线超市");
Response.Write("<br/>" + "你的登录密码为:" + Request["pwd"].ToString());
}
else
{
Response.Write("<script language=\"javascript\">alert('登录失败')</script>");
}
}
} 展开
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
public partial class login : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
}
protected void Button1_Click(object sender, EventArgs e)
{
string username = TextBox1.Text;
string userpwd = TextBox2.Text;
Response.Redirect("loginsuccess.aspx?name=" + username + "&loginsuccess.aspx?pwd=" + userpwd);
}
protected void Button2_Click(object sender, EventArgs e)
{
TextBox1.Text = " ";
TextBox2.Text = " ";
}
}
这是loginsuccess.aspx文件
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
public partial class loginsuccess : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
if (Request["name"] == "admin" && Request["pwd"] == "123")
{
Response.Write("<br/>" + Request["name"].ToString() + ",欢迎你进入校园在线超市");
Response.Write("<br/>" + "你的登录密码为:" + Request["pwd"].ToString());
}
else
{
Response.Write("<script language=\"javascript\">alert('登录失败')</script>");
}
}
} 展开
展开全部
Request["name"] 、Request["pwd"] 没有取到值
Response.Redirect("loginsuccess.aspx?name=" + username + "&loginsuccess.aspx?pwd=" + userpwd);这句话是错误的
Response.Redirect("loginsuccess.aspx?name=" + username + "&pwd=" + userpwd);这样才是正确的
如果您的参数中有中文则建议您进行加码和解码 或者修改 编码格式
Response.Redirect("loginsuccess.aspx?name=" + username + "&loginsuccess.aspx?pwd=" + userpwd);这句话是错误的
Response.Redirect("loginsuccess.aspx?name=" + username + "&pwd=" + userpwd);这样才是正确的
如果您的参数中有中文则建议您进行加码和解码 或者修改 编码格式
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询