.net新手请帮忙

来源:百度知道 编辑:UC知道 时间:2024/06/22 03:47:41
public partial class _Default : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
if(!Page.IsPostBack)
{
this.username.Text="";
this.userpwd.Text="";
}
this.sshclose.Attributes.Add("onclick","window.close();");

}
protected void sshclear_Click(object sender, EventArgs e)
{
this.username.Text = "";
this.userpwd.Text = "";
}

protected void sshlogin_Click(object sender, EventArgs e)
{
string name = Request["username"].ToString();
string pwd = Request["userpwd"].ToString();
if (name == "a" && pwd == "a")
{
Response.Redirect("main.aspx");
}
else
{

直接跳转到这个main页面:
public partial class main : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
if(Request["username"]!=null&&Request["userpwd"]!=null)
{
string name = Request["username"].ToString();
string pwd = Request["userpwd"].ToString();
if (name == "a" && pwd == "a")
{
Response.Redirect("main.aspx");
}
Response.Redirect("default.aspx");
}

}

既然登录成功了!为了后面方便使用!直接存session好了!

最好先作个判断
if(Request["name"]!=null)
{
string name=Re.....
}

1.
Default.aspx.cs中
Response.Redirect("main.aspx?username="+name+"&userpwd="+pwd);

main.aspx.cs中
string name = this.Request.QueryString["username"];
string pwd = this.Request.QueryString["userpwd"];

2.
Default.aspx.cs中<