我是这样做的阿 /Dim MyCookie As New HttpCookie("MyCookie")
MyCookie.Value = Session("UserName")
Response.Cookies.Add(MyCookie)
'后改动2003/07/08
FormsAuthentication.SetAuthCookie(Session("UserName"), True)/////////////////////////////////////////////tbUser.text=Context.User.Identity.Name
谁能说点正事啊 /////////////////////////////
<authentication mode="Forms">
<forms name="YourAuthName" loginUrl="Login.aspx"
protection="All" path="/"></forms>
</authentication>
this.cookie = new HttpCookie("test");
this.cookie.Values.Add("loginid", this.txtloginid.Text);
this.cookie.Expires = DateTime.MaxValue;
base.Response.AppendCookie(this.cookie);取出Cookie并赋值给用户文本框做为默认值:
this.cookie = this.Request.Cookies["test"];
this.txtloginid.Text = this.cookie.Values["loginid"];楼主保存了Cookie,但你并没有把Cookie取出赋值给文本框啊。
this.cookie = new HttpCookie("MyCookie");
this.cookie.Values.Add("UserName", this.tbUser.Text);
this.cookie.Expires = DateTime.MaxValue;
base.Response.AppendCookie(this.cookie);在Page_Load事件里取出Cookie赋值
if (this.Request.Cookies["MyCookie"] != null)
{
this.cookie = this.Request.Cookies["MyCookie"];
this.tbUser.Text = this.cookie.Values["UserName"];
}