如何从后面的代码 (C#) 访问和使用 javascript 变量。经过研究,我实现了访问变量的过程,但我仍然没有得到变量的值。我哪里错了?
//Javascript
<script type="text/javascript">
function OnSucceeded() {
var status = 65;
var state = "pass value"
document.getElementById("getValue").value = status;
document.getElementById("getvalues").value = state;
}
</script>
//
<asp:HiddenField ID="getValue" runat="server" Value="" />
<asp:HiddenField ID="getvalues" runat="server" Value="" />
<asp:Button ID="Button1" runat="server" OnClientClick="OnSucceeded()" Text="Button"
OnClick="Button1_Click" />
//C# code behind
ClientScript.RegisterStartupScript(this.GetType(), "myalert", "alert('" + getvalues.Value + "');", true);