Javascript is not recognising any of the hidden variables on this web form. It simply reports them to be null. I tried declaring a new variable without "runat=server". No luck.
<html>
<head>
<script language="javascript">
function Print() {
alert(document.getElementById('hdnMyHidden'));
alert(document.getElementById('hdnMyHidden').value);
var strmyCodes = document.getElementById("hdnmyCode").value;
var strmyDesc = document.Form1.hdnmyCode.value;
alert(strmyCodes);
alert(strmyDesc);
alert('hello from asp.net');
}
</script>
</head>
<body scroll="no">
<form id="Form1" method="post" runat="server">
<input id="hdnmyCode" type="hidden" runat="server" name="hdnmyCode">
<input id="hdnMyHidden" type="hidden" name="hdnMyHidden">
<input id="btn" type="submit" name="save" onclick="javascript:Print()">
</form>
</body>
</html>
When queried the value, it says "Object required" and when queried the variable, it says "null".
Environment :
VS2008, ASP.NET, VB.NET
.NET 2.0/3.5
IE 7.0
IIS 5
WinXP SP2