I have a calendar control that is hosted on an iframe. I get a javascript error when I click on a date on the calendar. window.top.document.getElementById(..) is null or not an object
The iframe is hosted on another page ConfigSettings.aspx
The code in the calendar control code behind is:
Dim sjscript As String = "<script language=""javascript"" type=""text/javascript"">"
sjscript &= "window.top.document.getElementById('" & HttpContext.Current.Request.QueryString("DateTextID") & "').value = '" & Calendar1.SelectedDate & "';"
sjscript &= "window.top.document.getElementById('" & HttpContext.Current.Request.QueryString("DateTextID") & "1').style.display = 'none';"
sjscript = sjscript & "</script" & ">"
Literal1.Text = sjscript
The html code is:
<input type="text" class="TextBox" id="ToDate" runat="server"/>
<a href="javascript:ShowCalendar('ToDate1')"><img src="images/Calendar.jpg" border="0" /></a>
<iframe src="Calendar.aspx?DateTextID=ToDate" style="display:none; width:200px; height:100px" name="ToDate1" id="ToDate1"></iframe>
<asp:Label runat="server" ID="lblEndTime" Text="End Time:"></asp:Label>
What would be causing the error?
http://www.example.com– as the top level window?