title: Javascript error: 'window.top.document.getElementById(...)' is null or not an object
body: <p>I am getting a javascript error when I attempt to click on my calendar control.  </p>
  
  <p><strong>The html code is:</strong>   </p>
  
  <pre><code>        &lt;td align="left" style="width:50%;"&gt;&lt;asp:Label runat="server" CssClass="TextFontBold" ID="lblStartDate" Text="Start Date:"&gt;&lt;/asp:Label&gt;
              &lt;input type="text" class="TextBox" id="FromDate" runat="server"/&gt;&lt;a href="javascript:ShowCalendar('FromDate1')"&gt;&lt;img src="images/Calendar.png" border="0" /&gt;&lt;/a&gt;
              &lt;iframe src="Calendar.aspx?DateTextID=FromDate" style="display:none; top: 0px; left: 0px; width:245px; height:164px" frameborder="0" scrolling="no" name="FromDate1" id="FromDate1"&gt;&lt;/iframe&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
              &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;asp:Label runat="server" CssClass="TextFontBold" ID="lblPromoStartTime" Text="Start Time:"&gt;&lt;/asp:Label&gt;
          &lt;/td&gt;  
  </code></pre>
  
  <p>When I click on a date in the calendar control, this code is executed on the code-behind:  </p>
  
  <pre><code>Protected Sub Calendar1_SelectionChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles Calendar1.SelectionChanged
      Dim strjscript As String = "&lt;script language=""javascript"" type=""text/javascript""&gt;"
      strjscript &amp;= "window.top.document.getElementById('" &amp; HttpContext.Current.Request.QueryString("DateTextID") &amp; "').value = '" &amp; Calendar1.SelectedDate &amp; "';"
      strjscript &amp;= "window.top.document.getElementById('" &amp; HttpContext.Current.Request.QueryString("DateTextID") &amp; "1').style.display = 'none';"
      strjscript = strjscript &amp; "&lt;/script" &amp; "&gt;"
      Literal1.Text = strjscript
  End Sub  
  </code></pre>
  
  <p>The error I am getting is <strong>'window.top.document.getElementById(...)' is null or not an object</strong>  </p>
  
  <p>I do have an object called FromDate.<br>
  What else could be causing this error?</p>