日期:2014-05-17 浏览次数:20550 次
using System; using System.Data; using System.Configuration; using System.Collections; using System.Web; using System.Web.Security; using System.Web.UI; using System.Web.UI.WebControls; using System.Web.UI.WebControls.WebParts; using System.Web.UI.HtmlControls; namespace HtmlCombox { public partial class _Default : System.Web.UI.Page { protected void Page_Load(object sender, EventArgs e) { if (Request.Cookies["UserModel"] != null) { int UserID = int.Parse(Request.Cookies["UserModel"].Values["UserID"]); //自动登陆系统 string temp = ""; } } protected void Button1_Click(object sender, EventArgs e) { HttpCookie c = new HttpCookie("UserModel"); UserInfo model = new UserInfo(); model.UserID = 100; c.Values.Add("UserID", model.UserID.ToString()); //登陆成功加HttpCookie到客户端 Response.Cookies.Add(c); } } [Serializable] public class UserInfo { int userID; int userName; /// <summary> /// UserName /// </summary> public int UserName { get { return userName; } set { userName = value; } } /// <summary> /// UserID /// </summary> public int UserID { get { return userID; } set { userID = value; } } } }