(1)Javascript访问C#后台变量或函数
A.通过<%=%>的形式访问
var str = "<%=GetStr() %>";
var str = "<%=str1 %>";
B.通过隐藏域访问
<input id="hidden1" type="hidden" runat="server" />
var str = document.getElementById("hidden1").value;
C. 页面注册一段脚本
string strTemp = "Hello";
ClientScript.RegisterStartupScript( this.GetType(), "123", "<script> var temp=" + strTemp + "</script>" );
(2)C#后台访问Javascript函数或变量
A. 通过页面注册脚本
ClientScript.RegisterStartupScript( this.GetType(), "123", "<script> func(); </script>" );
B. 通过隐藏域访问
TextBox1.Text = hidden1.value;
hidden1.value = "Hello";