ASP.NET: Why is my JavaScript object set to null?

Posted by Giffyguy on Stack Overflow See other posts from Stack Overflow or by Giffyguy
Published on 2010-04-29T17:52:48Z Indexed on 2010/04/29 18:07 UTC
Read the original article Hit count: 292

I have a <script> that contains this line:

var tbl = document.getElementById("<%= this.tblSelection.ClientID %>");

... but tbl always ends up being set to null.

The table is declared like this:

<asp:Table ID="tblSelection" runat="server" CellPadding="2" CellSpacing="0"
    cols="1" style="position: absolute; top: 0%; right: 0%">

Both the script and the table are in the same master page file.

What could be causing this?

EDIT: I should mention that this script is executed on onload

© Stack Overflow or respective owner

Related posts about ASP.NET

Related posts about JavaScript