cerebalbore
Technical User
I'm a bit of a novice when it comes to JavaScript and I'm slowly getting there using bits and pieces in my project where needed, but this morning something utterly baffling occured. Let me explain...
I had two ASP HiddenFields, one with an ID of WO and the other STEP, both populated on page load (code behind) like this:
<asp:HiddenField ID="WO" runat="server"/>
<asp:HiddenField ID="STEP" runat="server"/>
And after the HTML side of things, I had a simple JavaScript function that got the values of these fields using these statements:
var foo = document.getElementById('<%= WO.ClientID %>').value;
var bar = document.getElementById('<%= STEP.ClientID %>').value;
However I was getting a compile error against the second statement(BC30201 - Expression Expected), which made no sense to me whatsoever. I changed the STEP one to ('ContentPlaceholder3_STEP'), which worked so I knew it wasn't that the field wasn't there. Google wasn't being much help as nobody seemed to have the same problem.
Did some quick tests adding another hidden field and a quick function to grab it's value, and that worked too. The last thing I tried was to change the ID of the hidden field causing the error, and it worked. That changed the ID from STEP to STEP1.
So, has anyone else experienced this behaviour? Why would STEP as an ID be 'illegal'?? Am I wrong in assuming it's the ID causing the issue??
I'm such a noob
I had two ASP HiddenFields, one with an ID of WO and the other STEP, both populated on page load (code behind) like this:
<asp:HiddenField ID="WO" runat="server"/>
<asp:HiddenField ID="STEP" runat="server"/>
And after the HTML side of things, I had a simple JavaScript function that got the values of these fields using these statements:
var foo = document.getElementById('<%= WO.ClientID %>').value;
var bar = document.getElementById('<%= STEP.ClientID %>').value;
However I was getting a compile error against the second statement(BC30201 - Expression Expected), which made no sense to me whatsoever. I changed the STEP one to ('ContentPlaceholder3_STEP'), which worked so I knew it wasn't that the field wasn't there. Google wasn't being much help as nobody seemed to have the same problem.
Did some quick tests adding another hidden field and a quick function to grab it's value, and that worked too. The last thing I tried was to change the ID of the hidden field causing the error, and it worked. That changed the ID from STEP to STEP1.
So, has anyone else experienced this behaviour? Why would STEP as an ID be 'illegal'?? Am I wrong in assuming it's the ID causing the issue??
I'm such a noob