开发者

Javascript error: 'window.top.document.getElementById(...)' is null or not an object

I am getting a javascript error when I attempt to click on my calendar control.

The html code is:

        <td align="left" style="width:50%;"><asp:Label runat="server" CssClass="TextFontBold" ID="lblStartDate" Text="Start Date:"></asp:Label>
            <input type="text" class="TextBox" id="FromDate" runat="server"/><a href="javascript:ShowCalendar('FromDate1')"><img src="images/Calendar.png" border="0" /></a>
            <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"></iframe>&nbsp;&nbsp;&nbsp;&nbsp;
            &nbsp;&nbsp;&nbsp;&nbsp;<asp:Label runat="server" CssClass="TextFontBold" ID="lblPromoStartTime" Text="Start Time:"></asp:Label>
        </td>  

When I click on a date in the calendar control, this code is executed on the code-behind:

Protected Sub Calendar1_SelectionChanged(ByVal se开发者_开发百科nder As Object, ByVal e As System.EventArgs) Handles Calendar1.SelectionChanged
    Dim strjscript As String = "<script language=""javascript"" type=""text/javascript"">"
    strjscript &= "window.top.document.getElementById('" & HttpContext.Current.Request.QueryString("DateTextID") & "').value = '" & Calendar1.SelectedDate & "';"
    strjscript &= "window.top.document.getElementById('" & HttpContext.Current.Request.QueryString("DateTextID") & "1').style.display = 'none';"
    strjscript = strjscript & "</script" & ">"
    Literal1.Text = strjscript
End Sub  

The error I am getting is 'window.top.document.getElementById(...)' is null or not an object

I do have an object called FromDate.

What else could be causing this error?


Try window.parent.document.getElementById() instead of window.top.document.getElementById()


Have you tried parent.document.getElementById(...)? Just an idea...

Edited as suggested by pimvdb

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜