分兩步:
1. ASP.Net 頁面類中
public string tmp; //必須為public
private void Page_Load(object sender, System.EventArgs e)
{
tmp = "test string";
}
2. Javascrip 代碼
<script language="Javascript" type="text/Javascript">
var tmp = "<%=tmp%>"; //給腳本變量賦值
function showMsg(tmp)
{
alert(tmp);
}
</script>