Hi Folks,
If you have used RJS Pop Calendar in your project, you must have faced a problem of toggling (enable or disable) the pop calendar using a client-side script like javascript. Here is a simple solution for the same.
Steps
  1. Include the below javascript in your page:
    1. function ToggleCalender()
    2. {
    3. var chkToggleCal = document.getElementById('<%= chkToggleCal.ClientID %>');
    4. var spanCal = document.getElementById('<%= PopCalDate.ClientID %>' + '_Control');
    5. var imgCal = spanCal.getElementsByTagName("img");
    6. if (chkToggleCal.checked)
    7. {
    8. imgCal[0].src = "PopCalendar2005/Calendar.gif";
    9. spanCal.onclick = function ShowCal()
    10. {
    11. __PopCalShowCalendar('<%= txtCal.ClientID %>', this);
    12. };
    13. }
    14. else
    15. {
    16. imgCal[0].src = "PopCalendar2005/DisableCalendar.gif";
    17. spanCal.onclick = function LockCal()
    18. {
    19. };
    20. }
    21. }
  2. Include the following lines of code in your Code-Behind page in your page_load event:
    1. if (!Page.IsPostBack)
    2. {
    3. chkToggleCal.Attributes.Add("onclick", "javascript:ToggleCalender();");
    4. }
To modify the above mentioned script, you need to know the following:
  • chkToggleCal: ASP.NET Control which will enable or disable pop calendar.
  • PopCalDate: Pop calendar control you want to enable or disable.
  • txtCal: ASP.NET Control mentioned in Control property of Pop Calendar.
Attached is a sample application to demonstrate the working of this script.
Now, you can toggle the state of the pop calendar from the client script. Feel free to provide your comments.