使用cookie,给你点代码: 登录时: Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click If 条件满足 Then Dim aCookie As New HttpCookie("userinfo") aCookie.Values("userName") = TextBox1.Text aCookie.Values("userpwd") = TextBox2.Text aCookie.Expires = DateTime.Now.AddDays(500) Response.Cookies.Add(aCookie) Response.Redirect("tptj.aspx") Else Label3.Visible = True Label3.Text = "用户名或密码输入错误!" End If End Sub是第二个页面: Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load If Request.Cookies("olsy") Is Nothing Then Response.Redirect("登录页面") Else 继续 end if
登录时:
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
If 条件满足 Then
Dim aCookie As New HttpCookie("userinfo")
aCookie.Values("userName") = TextBox1.Text
aCookie.Values("userpwd") = TextBox2.Text
aCookie.Expires = DateTime.Now.AddDays(500)
Response.Cookies.Add(aCookie)
Response.Redirect("tptj.aspx")
Else
Label3.Visible = True
Label3.Text = "用户名或密码输入错误!"
End If
End Sub是第二个页面:
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
If Request.Cookies("olsy") Is Nothing Then
Response.Redirect("登录页面")
Else
继续
end if
{
// 在此处放置用户代码以初始化页面
if(Session["User_id"]==null)
Response.Redirect("logon.aspx");
else
Response.Redirect("index.aspx")
}
Session["User_id"]保存用户名,在用户成功登录后,你把用户名赋给它就行了
logon.aspx //登录页面
index.aspx //系统页面
也可以使用session,用法一样。