在我的MS SQL表中,我從一條記錄中讀取了城市的「time_zone」。從Javascript訪問C#變量?
然後我想在JavaScript函數中使用此時區爲該城市創建數字時鐘。
目前,我試圖從
這裏設置變量TIME_ZONE從是一個Default.aspx的代碼片段:
function showtime() {
zone(hiddenZone,clock);
}
window.onload = showtime;
</script>
</head>
<body>
<form id="form1" runat="server">
<div>
<span id="clock"></span>
<asp:HiddenField ID="hiddenZone" runat="server" />
<asp:Label Text="" ID="lblXml" runat="server"></asp:Label>
</div>
</form>
</body>
</html>
唯一的C#我在Default.aspx.cs的是:
hiddenZone.Value=timeZone;
我查過了,timeZone從數據庫中讀入了正確的值。
我從JS收到「欣欣」功能的錯誤消息是:「hiddenZone未定義」
我怎樣才能獲得的「TimeZone」 C#可變進我的Javascript和使用它的功能是什麼?
使用.NET 4.0的ClientIdMode屬性,您將在這種情況下擁有更大的靈活性。 http://www.dotnetcube.com/post/Overview-of-NET-40-features-e28093-ASPNET-40-ClientIDMode.aspx – DotnetDude 2009-07-15 17:29:17