c# cookie的使用,以及与javascript cookie的交互
C#:
创建:
HttpCookie cookie = new HttpCookie("regID");
cookie .Value = username;
cookie .Expires = DateTime.Now.AddDays(1);
Response.Cookies.Add(cookie);
创建有子键的:
Response.Cookies["user"]["userName"] = Server.UrlEncode("大西瓜");//使用UrlEncode是为了使用javascript取出时不是乱码
或:
HttpCookie cookie=new HttpCookie("user");
cookie.Values["userName"] = "aaa"; //cookie.Values.Add("userName","aaa");
cookie .Expires = DateTime.Now.AddDays(1);
Response.Cookies.Add(cookie) //Response.AppendCookie(cookie) ;
消除:直接删除没法删,因为COOKIE创建以后就保存在用户机器上了而不是在服务端
这样全部删除:
private HttpCookie cookie = null;
private string cookieName = string.Empty;
for (int i = 0; i < Request.Cookies.Count; i++)
{
cookieName = Request.Cookies[i].Name;
cookie = new HttpCookie(cookieName);
cookie .Expires = DateTime.Now.AddDays(-1);
Response.Cookies.Add(cookie );
}
删除子键:
HttpCookie cookie;
cookie = Request.Cookies["userInfo"]; &nbs
相关文档:
利用 Page.RegisterStartupScript("", "<script language='javascript'> results();</script>");
或者是 Page.RegisterClient ......
要在你的网页中使用 JavaScript ,你首先必须要知道该将它放在哪儿。其实很简单,只要在你的网页(HTML文件)中插入
<SCRIPT> 和 </SCRIPT> 标记对,你就可以在这两个标记队之间插入你的 JavaScript 代码了:
<script>
alert("Hello world!");
</script>
另外,你也可以将 Ja ......
using System;
using System.Web;
namespace pub.mo
{
public class js
{
private js() { }
private static string scr_j1 = "<mce:script type=\"text/javascript\"><!--
";
private static string scr_j2 = "
// --></mce:script>";
/// <summa ......
using System;
using System.Collections.Generic;
using System.Text;
using System.Web;
namespace pub.mo
{
public class request
{
private request() { }
/// <summary>
/// 获取session
/// </summary>
/// <param name="_session_name" ......
  ......