Disable RJS Pop Calendar using Client-Side Script

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 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.   
    7.      if (chkToggleCal.checked)   
    8.      {  
    9.             imgCal[0].src = "PopCalendar2005/Calendar.gif";  
    10.             spanCal.onclick = function ShowCal()   
    11.             {  
    12.                  __PopCalShowCalendar('<%= txtCal.ClientID %>'this);   
    13.             };  
    14.      }  
    15.      else  
    16.      {   
    17.             imgCal[0].src = "PopCalendar2005/DisableCalendar.gif";   
    18.             spanCal.onclick = function LockCal()  
    19.            {  
    20.   
    21.            };    
    22.      }   
    23. }  
  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();");  

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 pop calendar from client script. Feel free to provide your comments.
Ebook Download
View all
Learn
View all