public string mainMenu(string sKey){
string sRelust = "";
if (Request.QueryString["main"] == sKey)
{
sRelust = "class=\"active\"";
}
return sRelust;
}
public string subMenu(string sKey)
{
string sRelust = "";
if (Request.QueryString["sub"] == sKey)
{
sRelust = "class=\"current\"";
AddCookie("menu", "sub", sKey);
}
return sRelust;
}
public void AddCookie(string sName, string sKey, string sValue)
{
//註冊Cookie
//產生一個Cookie
HttpCookie cookie = new HttpCookie(sName);
//設定單值
cookie.Values.Add(sKey, sValue);
//設定過期日
cookie.Expires = DateTime.Now.AddDays(1);
//寫到用戶端
Response.Cookies.Add(cookie);
}
Script
ASP.NET
ASP.NET 註冊Cookie的方法
範例如下
訂閱:
張貼留言 (Atom)
沒有留言:
張貼留言