function getCookies(name)
{
  var arr = document.cookie.match(new RegExp("(^| )"+name+"=([^;]*)(;|$)"));
  if(arr != null) return unescape(arr[2]); return null;
}
getCookies(name)怎么传递给C#里面的Label1.Text
主要是用JS读取COOKIE然后传递给C#并显示出来请问怎么实现???????

解决方案 »

  1.   

    VS2005
    试试
    document.getElementById('<%#=Label1.ClientID%>').innerText=getCookies(name);VS2003没有ClientID
      

  2.   

    document.getElementById("Label1").innerText=getCookies(name);
    VS2003有ClientID
      

  3.   

    先用js把值写到一个隐藏的服务器控件(hidden)中,然后用c#程序来读取该控件的值
      

  4.   

    添加一个隐藏控件:<input type="hidden" id = "HidId" runat="server">function getCookies(name)
    {
      var arr = document.cookie.match(new RegExp("(^| )"+name+"=([^;]*)(;|$)"));
      if(arr != null) 
          document.HidId.value = unescape(arr[2]); 
      document.HidId.value = null;
    }后台接受
    Request.Form["HidId"]
      

  5.   

    document.getElementById("Label1").innerText=getCookies(name);
    这个应该行
      

  6.   

    用隐藏控件,并且设置为在服务器属性.在js中设置,在后台直接(同取控件的值value)获取即可.