如题~
好像在.net中加入了ajax框架就不能在cs代码中访问页面控件了,郁闷,现在我是在js代码中记录cookie的,可是别得页面是在cs代码中读取,可是这样读不到cookie的值

解决方案 »

  1.   

    asp.net读取和写Cookie是经过加密的,Asp.net 1.1的Cookie在.Net 2.0下都读不了,因为.Net2.0对Cookie的加密算法变了。
    实在需要使用.Net来读js写的Cookie的话,你找一下.Net中加密Cookie的算法研究一下。
      

  2.   

    HttpCookie hcookie = Request.Cookies["info"];
                if (hcookie != null)
                {
                    this.lbMsg.Text = Server.UrlDecode(hcookie.Value);
                }
      

  3.   

    你还是在页面上放一个HIDDEN控件好了.这样子更方便
      

  4.   

    decodeURIComponent(escape(strCookie))setcookie函数会对cookie变量的值做一次urlencode操作
    因为你恰好使用了utf-8编码,所以操作起来就很方便了。如果是其他编码,比如gb2312就需要就需要自己书写编码函数了
      

  5.   

    我测试的结果好象没有什么呀...
    不过,我都是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>