I have this simple code:
<html>
<body>
<form name="f1">
<asp:Label name="lbl" runat="server" Text="Label" onclick="lblClick()"></asp:Label>
</form>
<script type="text/javascript">
function lblClick(){
document.f1.lbl.text="new text";}
</script>
</body>
</html>
It doesn’t work, it gives me:
Microsoft JScript runtime error: ‘document.getElementById(…)’ is null or not an object … ,
I can’t even change the label text ….why?!!!
let us remember that asp.net renames your controls for you.
Adamantium’s answer will also provide you the functionality you’re after.