Wednesday, April 13, 2011

Javascript calendar not working

Hi.

My JavaScript calender is working in IE but it is not working in Mozilla.

My code:

  <table>
   <tr style="height: 5px;">
    <td>
     <asp:TextBox ID="txtBorderedDate" runat="server" CssClass="TextBoxMandatory" Enabled="false"></asp:TextBox>
    </td>
    <td class="FieldButton_bg" style="height: 5px;"> 
     <a onclick="javascript:showCalendarControl(ctl00_SaralConetentPlaceHolder_txtBorderedDate);" href="#">
       <img src="../Images/iconCalendar.png" style="width: 20px; height: 20px; vertical-align: bottom;" border="0" />
     </a>
    </td>
   </tr>
  </table>
From stackoverflow
  • I'm not sure if this has anything to do with the problem (you should post some more of your code), but you shouldn't hard code the ID of the controls in ASP.NET. Also, I think some quotes might be missing in the showCalendarControl() call.

    Replace this:

    <a onclick=
     "javascript:showCalendarControl(ctl00_SaralConetentPlaceHolder_txtBorderedDate);" ...
    

    With this:

    <a onclick="showCalendarControl('<%= txtBorderedDate.ClientID %>');" ...
    

    Some of the parent controls of txtBorderedDate might get rendered differently in different borders, thus resulting in a different client-side ID of the textbox control.

    Cerebrus : +1 but I doubt this is reason... JS based Calendars are complex dynamic structures that have a lot of dynamically created elements. In this case, he seems to be passing the ID of the textbox which will receive the selected value of the calendar.
    M4N : It's hard to tell, with only that short code extract.

0 comments:

Post a Comment

Note: Only a member of this blog may post a comment.