How To Assign Value To HiddenField
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title>Assign Value To HiddenField</title>
<script type="text/javascript" language="javascript">
window.onload = function () {
document.getElementById("HiddenField1").value = "B";
}
</script>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:HiddenField ID="HiddenField1" runat="server" Value="A" />
<asp:Button ID="Button1" runat="server" Text="Button" onclick="Button1_Click" />
</div>
</form>
</body>
</html>
protected void Button1_Click(object sender, EventArgs e)
{
Response.Write(HiddenField1.Value);
}
0 留言