javascirpt和aspx如何交换数据

来源:百度知道 编辑:UC知道 时间:2024/06/27 18:58:36
在一个aspx页面中定义的变量如何在这个页面的javscript中读取

一般用<input hidden>来传递
比如
.cs文件中有string tranValue
private void Page_Load()
{
string tranValue="hello";
....
}
.aspx文件中,strValue要获取这个tranValue
....
<script language=javascript>
function window_onload()
{
strValue=tranValue.value
}
</script>
<body onload="window_onload()">
<input type=hidden id=tranValue value="<%=tranValue%>">
....