如题~
好像在.net中加入了ajax框架就不能在cs代码中访问页面控件了,郁闷,现在我是在js代码中记录cookie的,可是别得页面是在cs代码中读取,可是这样读不到cookie的值
好像在.net中加入了ajax框架就不能在cs代码中访问页面控件了,郁闷,现在我是在js代码中记录cookie的,可是别得页面是在cs代码中读取,可是这样读不到cookie的值
解决方案 »
- web 显示大图片 带滚动条的,如何实现鼠标拖动浏览,就和地图哪个爬行一样
- enterprise library3.1 怎样配置Accese数据库路径??????
- 如何取得datagrid里面EditItemTemplate 的textbox值
- winwedmail不能收发邮件怎么回事?
- 想解决一个互联网成员合作开发项目的问题
- ◆◆如何传递1组SQL参数◆并在存储过程中遍历?◆◆ ◆◆
- c#读取4万多行的csv文件,程序总是死掉
- 这 算不算 给自己 倒分!??
- Silverlight 中xmal 报异常XamlParseException: [Line: 0 Position: 0]
- 怎么写服务器控件的客户端事件阿?
- 装了VS2008后。。。(高手们进来看看)
- 此结束标记没有匹配的开始标记!无法切换视图。
实在需要使用.Net来读js写的Cookie的话,你找一下.Net中加密Cookie的算法研究一下。
if (hcookie != null)
{
this.lbMsg.Text = Server.UrlDecode(hcookie.Value);
}
因为你恰好使用了utf-8编码,所以操作起来就很方便了。如果是其他编码,比如gb2312就需要就需要自己书写编码函数了
不过,我都是UTF8的...
现在为什么还不统一为UTF8呢?
=============================================================
<%@ Page language="C#" %>
<%
HttpCookieCollection cookies;HttpCookie oneCookie;cookies = Request.Cookies;string[] cookieArray = cookies.AllKeys;System.IO.StringWriter writer = new System.IO.StringWriter();for (int i=0; i < cookieArray.Length; i++) { oneCookie =cookies[cookieArray[i]];
Server.UrlDecode(oneCookie.Value,writer);
Response.Write(oneCookie.Name + " - " + writer.ToString());}
%><script type="text/javascript" src="http://code.jquery.com/jquery-latest.pack.js"></script>
<script type="text/javascript" src="http://jquery.com/dev/svn/trunk/plugins/cookie/jquery.cookie.js?format=txt"></script><script type="text/javascript" Language="JavaScript">
// <![CDATA[
function set(){
$.cookie('the_cookie', '中文值'); // set cookie
}function get(){
alert($.cookie('the_cookie')); // get cookie
}function del(){
$.cookie('the_cookie', '', { expires: -1 }); // delete cookie
}
$(document).ready(function(){
//$.cookie('the_cookie')); // get cookie
//$.cookie('the_cookie', 'the_value'); // set cookie
//$.cookie('the_cookie', 'the_value', { expires: 7 }); // set cookie with an expiration date seven days in the future
//$.cookie('the_cookie', '', { expires: -1 }); // delete cookie
});// ]]>
</script>
<body>
<input type="button" value="setCookie" onclick="set();" />
<input type="button" value="getCookie" onclick="get();" />
<input type="button" value="delCookie" onclick="del();" /></body>