在后台要调用js里的变量值,不要用隐藏域url传参什么的,要用c#代码获取。以前有看到过,现在找不到了,请高手帮忙写个例子。

解决方案 »

  1.   

    你可以使用cookie,
    ajax也是使用的隐藏域url传参的
      

  2.   


    <html>
    <body>
    <script>
    var c = 3;
    document.getElementById("frm1").src="a.aspx?c="+c;
    </script>
    <iframe id="frm1" src="a.aspx" />
    </body>
    </html>a.aspx.cspage_load
    {
    string c = Request["c"];
    }
      

  3.   

    js是在前端运行的,c#是后台运行的,你不用url怎么实现两者的通讯啊。用c#代码是不能直接获取js的变量值的。
      

  4.   

    在网上找到下面这样一段代码 
    IHTMLDocument2 vDocument = webBrowser1.Document.DomDocument as IHTMLDocument2;
            IHTMLWindow2 vWindow = vDocument.parentWindow;
            Type vWindowType = vWindow.GetType();
            object aaa = vWindowType.InvokeMember("变量名", BindingFlags.GetProperty, null, vWindow, new object[] { });但是搞不清webBrowser在哪里添加
      

  5.   

    <script type="text/javascript">
      x = window.XMLHttpRequest ? new XMLHttpRequest() : new ActiveXObject("MSXML2.XMLHTTP");
      x.open("GET","2.aspx",false)
      x.setRequestHeader("xx", "yyyyyyyyyy");
      x.send(null);
      alert(x.responseText)
      </script>2.aspx"if (Request.Headers["xx"] != null) Response.Write(Request.Headers["xx"]);