This is a migrated thread and some comments may be shown as answers.

Disabling Month Year Picker

3 Answers 266 Views
Calendar
This is a migrated thread and some comments may be shown as answers.
Igor Koretsky
Top achievements
Rank 1
Igor Koretsky asked on 06 Aug 2009, 04:07 PM

Hi everyone.

 

I have two requirements for date picker.

 

First I need a date picker object without the calendar day’s part where the user can only select a month and a year.

 

And second I need to be able to enable/disable the date picker depending on what option user selected in the radio button list control.

 

For the first requirement I found a custom implementation on

http://www.telerik.com/community/code-library/submission/b311D-mdkhb.aspx

and it is working just fine.

 

But when I try to disable date picker with ‘picker.set_enabled(false);’ statement

I am getting the following error:

Microsoft JScript runtime error: Sys.InvalidOperationException: Handler was not added through the Sys.UI.DomEvent.addHandler method.

 

Here is my simple web page:
Some how I placed 3 code blocks.
Please look at the top one only and ignore the other two. 

 

 

 

 

<%@ Page Language="C#" AutoEventWireup="true" Culture="en-US" CodeFile="Default.aspx.cs" 
    Inherits="_Default" %> 
 
<%@ Register Assembly="Telerik.Web.UI" Namespace="Telerik.Web.UI" TagPrefix="telerik" %> 
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> 
<html xmlns="http://www.w3.org/1999/xhtml">  
<head runat="server">  
    <title>Untitled Page</title> 
</head> 
<body> 
    <form id="form1" runat="server">  
    <asp:ScriptManager ID="ScriptManager1" runat="server">  
    </asp:ScriptManager> 
    <div> 
 
        <script type="text/javascript">  
            //override the onload event handler to change the picker after the page is loaded  
            window.onload = function()  
            {  
                window.setTimeout(function() { setCalendarTable(); }, 200)  
            }  
 
            function setCalendarTable()  
            {  
 
                var picker = $find("<%= RadDatePicker1.ClientID %>");  
                var calendar = picker.get_calendar();  
                var fastNavigation = calendar._getFastNavigation();  
 
                $clearHandlers(picker.get_popupButton());  
                $addHandler(picker.get_popupButton(), "click", function()  
                {  
                    var textbox = picker.get_textBox();  
                    //adjust where to show the popup table   
                    var x, y;  
                    var adjustElement = textbox;  
                    if (textbox.style.display == "none")  
                        adjustElement = picker.get_popupImage();  
 
                    var pos = picker.getElementPosition(adjustElement);  
                    x = pos.x;  
                    y = pos.y + adjustElement.offsetHeight;  
 
                    var e = {  
                        clientX: x,  
                        clientY: y  
                    };  
                    //synchronize the input date if set with the picker one  
                    var date = picker.get_selectedDate();  
                    if (date)  
                    {  
                        calendar.get_focusedDate()[0] = date.getFullYear();  
                        calendar.get_focusedDate()[1] = date.getMonth() + 1;  
                    }  
 
                    $get(calendar._titleID).onclick(e);  
                });  
 
                fastNavigation.OnOK =  
                    function()  
                    {  
                        var date = new Date(fastNavigation.Year, fastNavigation.Month, 1);  
                        picker.get_dateInput().set_selectedDate(date);  
                        fastNavigation.Popup.Hide();  
                    }  
 
 
                fastNavigation.OnToday =  
                    function()  
                    {  
                        var date = new Date();  
                        picker.get_dateInput().set_selectedDate(date);  
                        fastNavigation.Popup.Hide();  
                    }  
            }     
              
 
           //Enable or disable datepicker based upon if they choose never expires or expires/renews  
            function RadioButtonList1Change(){  
                var rdlist = document.getElementById("<%= RadioButtonList1.ClientID %>");  
                var optrdlist.getElementsByTagName('input');  
                var selected = 'empty';   
                for(var i = 0; i < opt.length ; i++){  
                    var rbRef = opt[i];   
                    if (rbRef.checked == true){  
                       selected = rbRef.value;  
                       break;  
                    }   
                }  
                var picker = $find("<%= RadDatePicker1.ClientID %>");  
                if (selected == '1'){  
                    picker.set_enabled(true);  
                }  
                else{  
                   if (selected == 'empty'){  
                   }  
                   else{    
                     picker.set_enabled(false);  
                  }     
                }  
            }  
 
        </script> 
 
 
       <asp:RadioButtonList ID="RadioButtonList1" runat="server" onclick="RadioButtonList1Change()">  
          <asp:ListItem Value="0">Never Expires</asp:ListItem> 
               <asp:ListItem Selected="True" Value="1">Expires/Renews after the close of : </asp:ListItem> 
       </asp:RadioButtonList> 
         
                                                                                                                                          
        <telerik:RadDatePicker ID="RadDatePicker1" runat="server" > 
            <DateInput DateFormat="MMMM yyyy" runat="server">  
            </DateInput> 
        </telerik:RadDatePicker> 
          
    </div> 
    </form> 
</body> 
</html> 
 
<%@ Page Language="C#" AutoEventWireup="true" Culture="en-US" CodeFile="Default.aspx.cs" 
    Inherits="_Default" %> 
 
<%@ Register Assembly="Telerik.Web.UI" Namespace="Telerik.Web.UI" TagPrefix="telerik" %> 
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> 
<html xmlns="http://www.w3.org/1999/xhtml">  
<head runat="server">  
    <title>Untitled Page</title> 
</head> 
<body> 
    <form id="form1" runat="server">  
    <asp:ScriptManager ID="ScriptManager1" runat="server">  
    </asp:ScriptManager> 
    <div> 
 
        <script type="text/javascript">  
            //override the onload event handler to change the picker after the page is loaded  
            window.onload = function()  
            {  
                window.setTimeout(function() { setCalendarTable(); }, 200)  
            }  
 
            function setCalendarTable()  
            {  
 
                var picker = $find("<%= RadDatePicker1.ClientID %>");  
                var calendar = picker.get_calendar();  
                var fastNavigation = calendar._getFastNavigation();  
 
                $clearHandlers(picker.get_popupButton());  
                $addHandler(picker.get_popupButton(), "click", function()  
                {  
                    var textbox = picker.get_textBox();  
                    //adjust where to show the popup table   
                    var x, y;  
                    var adjustElement = textbox;  
                    if (textbox.style.display == "none")  
                        adjustElement = picker.get_popupImage();  
 
                    var pos = picker.getElementPosition(adjustElement);  
                    x = pos.x;  
                    y = pos.y + adjustElement.offsetHeight;  
 
                    var e = {  
                        clientX: x,  
                        clientY: y  
                    };  
                    //synchronize the input date if set with the picker one  
                    var date = picker.get_selectedDate();  
                    if (date)  
                    {  
                        calendar.get_focusedDate()[0] = date.getFullYear();  
                        calendar.get_focusedDate()[1] = date.getMonth() + 1;  
                    }  
 
                    $get(calendar._titleID).onclick(e);  
                });  
 
                fastNavigation.OnOK =  
                    function()  
                    {  
                        var date = new Date(fastNavigation.Year, fastNavigation.Month, 1);  
                        picker.get_dateInput().set_selectedDate(date);  
                        fastNavigation.Popup.Hide();  
                    }  
 
 
                fastNavigation.OnToday =  
                    function()  
                    {  
                        var date = new Date();  
                        picker.get_dateInput().set_selectedDate(date);  
                        fastNavigation.Popup.Hide();  
                    }  
            }     
              
 
           //Enable or disable datepicker based upon if they choose never expires or expires/renews  
            function RadioButtonList1Change(){  
                var rdlist = document.getElementById("<%= RadioButtonList1.ClientID %>");  
                var optrdlist.getElementsByTagName('input');  
                var selected = 'empty';   
                for(var i = 0; i < opt.length ; i++){  
                    var rbRef = opt[i];   
                    if (rbRef.checked == true){  
                       selected = rbRef.value;  
                       break;  
                    }   
                }  
                var picker = $find("<%= RadDatePicker1.ClientID %>");  
                if (selected == '1'){  
                    picker.set_enabled(true);  
                }  
                else{  
                   if (selected == 'empty'){  
                   }  
                   else{    
                     picker.set_enabled(false);  
                  }     
                }  
            }  
 
        </script> 
 
 
       <asp:RadioButtonList ID="RadioButtonList1" runat="server" onclick="RadioButtonList1Change()">  
          <asp:ListItem Value="0">Never Expires</asp:ListItem> 
               <asp:ListItem Selected="True" Value="1">Expires/Renews after the close of : </asp:ListItem> 
       </asp:RadioButtonList> 
         
                                                                                                                                          
        <telerik:RadDatePicker ID="RadDatePicker1" runat="server" > 
            <DateInput DateFormat="MMMM yyyy" runat="server">  
            </DateInput> 
        </telerik:RadDatePicker> 
          
    </div> 
    </form> 
</body> 
</html> 
 
<FONT size=2>  
<P>&lt;%</P></FONT>  
<P><FONT color=#0000ff size=2>@</FONT><FONT size=2> </FONT><FONT color=#a31515   
size=2>Page</FONT><FONT size=2> </FONT><FONT color=#ff0000   
size=2>Language</FONT><FONT color=#0000ff size=2>="C#"</FONT><FONT size=2>   
</FONT><FONT color=#ff0000 size=2>AutoEventWireup</FONT><FONT color=#0000ff   
size=2>="true"</FONT><FONT size=2> </FONT><FONT color=#ff0000   
size=2>Culture</FONT><FONT color=#0000ff size=2>="en-US"</FONT><FONT size=2>   
</FONT><FONT color=#ff0000 size=2>CodeFile</FONT><FONT color=#0000ff   
size=2><FONT color=#0000ff size=2>="Default.aspx.cs"   
<P>&nbsp;</P></FONT>  
<P>&nbsp;</P></FONT>  
<P></P>  
<P><FONT color=#ff0000 size=2>Inherits</FONT><FONT color=#0000ff   
size=2>="_Default"</FONT><FONT size=2> %&gt;   
<P>&nbsp;</P>  
<P>&nbsp;</P>  
<P>&nbsp;&lt;%</P></FONT>  
<P></P>  
<P>&nbsp;</P>  
<P><FONT color=#0000ff size=2>@</FONT><FONT size=2> </FONT><FONT color=#a31515   
size=2>Register</FONT><FONT size=2> </FONT><FONT color=#ff0000   
size=2>Assembly</FONT><FONT color=#0000ff size=2>="Telerik.Web.UI"</FONT><FONT   
size=2> </FONT><FONT color=#ff0000 size=2>Namespace</FONT><FONT color=#0000ff   
size=2>="Telerik.Web.UI"</FONT><FONT size=2> </FONT><FONT color=#ff0000   
size=2>TagPrefix</FONT><FONT color=#0000ff size=2>="telerik"</FONT><FONT size=2>   
%&gt;   
<P>&nbsp;</P></FONT>  
<P></P>  
<P><FONT color=#0000ff size=2><FONT color=#0000ff size=2>&lt;!   
<P>&nbsp;</P>  
<P style="MARGIN: 0in 0in 0pt">&nbsp;</P></FONT>  
<P style="MARGIN: 0in 0in 0pt">&nbsp;</P>  
<P>&nbsp;</P></FONT>  
<P></P>  
<P><FONT color=#a31515 size=2>DOCTYPE</FONT><FONT size=2> </FONT><FONT   
color=#ff0000 size=2>html</FONT><FONT size=2> </FONT><FONT color=#ff0000   
size=2>PUBLIC</FONT><FONT size=2> </FONT><FONT color=#0000ff size=2>"-//W3C//DTD   
XHTML 1.0 Transitional//EN"</FONT><FONT size=2> </FONT><FONT color=#0000ff   
size=2><FONT color=#0000ff   
size=2>"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"&gt;   
<P>&nbsp;</P>  
<P>&nbsp;</P>  
<P>&nbsp;&lt;</P></FONT>  
<P>&nbsp;</P></FONT>  
<P></P>  
<P><FONT color=#a31515 size=2>html</FONT><FONT size=2> </FONT><FONT   
color=#ff0000 size=2>xmlns</FONT><FONT color=#0000ff size=2><FONT color=#0000ff   
size=2>="http://www.w3.org/1999/xhtml"&gt;   
<P>&nbsp;</P>  
<P>&nbsp;</P>  
<P>&nbsp;&lt;</P></FONT>  
<P>&nbsp;</P></FONT>  
<P></P>  
<P><FONT color=#a31515 size=2>head</FONT><FONT size=2> </FONT><FONT   
color=#ff0000 size=2>runat</FONT><FONT color=#0000ff size=2><FONT color=#0000ff   
size=2>="server"&gt;   
<P>&nbsp;</P>  
<P>&nbsp;</P>  
<P>&nbsp;</P></FONT>  
<P>&nbsp;</P></FONT>  
<P></P>  
<P><FONT color=#0000ff size=2>&lt;</FONT><FONT color=#a31515   
size=2>title</FONT><FONT color=#0000ff size=2>&gt;</FONT><FONT size=2>Untitled   
Page</FONT><FONT color=#0000ff size=2>&lt;/</FONT><FONT color=#a31515   
size=2>title</FONT><FONT color=#0000ff size=2><FONT color=#0000ff size=2>&gt;   
<P>&nbsp;</P>  
<P>&nbsp;</P>  
<P>&nbsp;&lt;/</P></FONT>  
<P>&nbsp;</P></FONT>  
<P></P>  
<P><FONT color=#a31515 size=2>head</FONT><FONT color=#0000ff size=2><FONT   
color=#0000ff size=2>&gt;   
<P>&nbsp;</P>  
<P>&nbsp;</P>  
<P>&nbsp;&lt;</P></FONT>  
<P>&nbsp;</P></FONT>  
<P></P>  
<P><FONT color=#a31515 size=2>body</FONT><FONT color=#0000ff size=2><FONT   
color=#0000ff size=2>&gt;   
<P>&nbsp;</P>  
<P>&nbsp;</P>  
<P>&nbsp;</P></FONT>  
<P>&nbsp;</P></FONT>  
<P></P>  
<P><FONT color=#0000ff size=2>&lt;</FONT><FONT color=#a31515   
size=2>form</FONT><FONT size=2> </FONT><FONT color=#ff0000 size=2>id</FONT><FONT   
color=#0000ff size=2>="form1"</FONT><FONT size=2> </FONT><FONT color=#ff0000   
size=2>runat</FONT><FONT color=#0000ff size=2><FONT color=#0000ff   
size=2>="server"&gt;   
<P>&nbsp;</P>  
<P>&nbsp;</P>  
<P>&nbsp;</P></FONT>  
<P>&nbsp;</P></FONT>  
<P></P>  
<P><FONT color=#0000ff size=2>&lt;</FONT><FONT color=#a31515   
size=2>asp</FONT><FONT color=#0000ff size=2>:</FONT><FONT color=#a31515   
size=2>ScriptManager</FONT><FONT size=2> </FONT><FONT color=#ff0000   
size=2>ID</FONT><FONT color=#0000ff size=2>="ScriptManager1"</FONT><FONT size=2>   
</FONT><FONT color=#ff0000 size=2>runat</FONT><FONT color=#0000ff size=2><FONT   
color=#0000ff size=2>="server"&gt;   
<P>&nbsp;</P>  
<P>&nbsp;</P>  
<P>&nbsp;</P></FONT>  
<P>&nbsp;</P></FONT>  
<P></P>  
<P><FONT color=#0000ff size=2>&lt;/</FONT><FONT color=#a31515   
size=2>asp</FONT><FONT color=#0000ff size=2>:</FONT><FONT color=#a31515   
size=2>ScriptManager</FONT><FONT color=#0000ff size=2><FONT color=#0000ff   
size=2>&gt;   
<P>&nbsp;</P>  
<P>&nbsp;</P>  
<P>&nbsp;</P></FONT>  
<P>&nbsp;</P></FONT>  
<P></P>  
<P><FONT color=#0000ff size=2>&lt;</FONT><FONT color=#a31515   
size=2>div</FONT><FONT color=#0000ff size=2><FONT color=#0000ff size=2>&gt;   
<P>&nbsp;</P>  
<P>&nbsp;</P>  
<P>&nbsp;</P></FONT>  
<P>&nbsp;</P></FONT>  
<P></P>  
<P><FONT color=#0000ff size=2>&lt;</FONT><FONT color=#a31515   
size=2>script</FONT><FONT size=2> </FONT><FONT color=#ff0000   
size=2>type</FONT><FONT color=#0000ff size=2><FONT color=#0000ff   
size=2>="text/javascript"&gt;   
<P>&nbsp;</P>  
<P>&nbsp;</P>  
<P>&nbsp;</P></FONT>  
<P>&nbsp;</P></FONT>  
<P></P>  
<P><FONT color=#008000 size=2><FONT color=#008000 size=2>//override the onload   
event handler to change the picker after the page is loaded   
<P>&nbsp;</P>  
<P>&nbsp;</P>  
<P>&nbsp;</P></FONT>  
<P>&nbsp;</P></FONT>  
<P></P>  
<P><FONT size=2>window.onload =   
<P>&nbsp;</P>  
<P>&nbsp;</P></FONT>  
<P></P>  
<P>&nbsp;</P>  
<P><FONT color=#0000ff size=2>function</FONT><FONT size=2>()   
<P>{</P>  
<P>window.setTimeout(</P></FONT>  
<P></P>  
<P>&nbsp;</P>  
<P><FONT color=#0000ff size=2>function</FONT><FONT size=2>() {   
setCalendarTable(); }, 200)   
<P>}</P>  
<P>&nbsp;</P></FONT>  
<P></P>  
<P><FONT color=#0000ff size=2>function</FONT><FONT size=2> setCalendarTable()   
<P>&nbsp;</P>  
<P>&nbsp;</P>  
<P>{</P>  
<P>&nbsp;</P></FONT>  
<P></P>  
<P><FONT color=#0000ff size=2>var</FONT><FONT size=2> picker =   
$find(</FONT><FONT color=#a31515 size=2>"&lt;%= RadDatePicker1.ClientID   
%&gt;"</FONT><FONT size=2>);   
<P>&nbsp;</P>  
<P>&nbsp;</P>  
<P>&nbsp;</P></FONT>  
<P></P>  
<P><FONT color=#0000ff size=2>var</FONT><FONT size=2> calendar =   
picker.get_calendar();   
<P>&nbsp;</P>  
<P>&nbsp;</P>  
<P>&nbsp;</P></FONT>  
<P></P>  
<P><FONT color=#0000ff size=2>var</FONT><FONT size=2> fastNavigation =   
calendar._getFastNavigation();   
<P>&nbsp;</P>  
<P>&nbsp;</P>  
<P>$clearHandlers(picker.get_popupButton());</P>  
<P>$addHandler(picker.get_popupButton(), </P></FONT>  
<P></P>  
<P>&nbsp;</P>  
<P><FONT color=#a31515 size=2>"click"</FONT><FONT size=2>, </FONT><FONT   
color=#0000ff size=2>function</FONT><FONT size=2>()   
<P>{</P>  
<P>&nbsp;</P></FONT>  
<P></P>  
<P><FONT color=#0000ff size=2>var</FONT><FONT size=2> textbox =   
picker.get_textBox();   
<P>&nbsp;</P>  
<P>&nbsp;</P>  
<P>&nbsp;</P></FONT>  
<P></P>  
<P><FONT color=#008000 size=2><FONT color=#008000 size=2>//adjust where to show   
the popup table   
<P>&nbsp;</P>  
<P>&nbsp;</P>  
<P>&nbsp;</P></FONT>  
<P>&nbsp;</P></FONT>  
<P></P>  
<P><FONT color=#0000ff size=2>var</FONT><FONT size=2> x, y;   
<P>&nbsp;</P>  
<P>&nbsp;</P>  
<P>&nbsp;</P></FONT>  
<P></P>  
<P><FONT color=#0000ff size=2>var</FONT><FONT size=2> adjustElement = textbox;   
<P>&nbsp;</P>  
<P>&nbsp;</P>  
<P>&nbsp;</P></FONT>  
<P></P>  
<P><FONT color=#0000ff size=2>if</FONT><FONT size=2> (textbox.style.display ==   
</FONT><FONT color=#a31515 size=2>"none"</FONT><FONT size=2>)   
<P>&nbsp;</P>  
<P>&nbsp;</P>  
<P>adjustElement = picker.get_popupImage();</P>  
<P>&nbsp;</P></FONT>  
<P></P>  
<P><FONT color=#0000ff size=2>var</FONT><FONT size=2> pos =   
picker.getElementPosition(adjustElement);   
<P>&nbsp;</P>  
<P>&nbsp;</P>  
<P>x = pos.x;</P>  
<P>y = pos.y + adjustElement.offsetHeight;</P>  
<P>&nbsp;</P></FONT>  
<P></P>  
<P><FONT color=#0000ff size=2>var</FONT><FONT size=2> e = {   
<P>&nbsp;</P>  
<P>&nbsp;</P>  
<P>clientX: x,</P>  
<P>clientY: y</P>  
<P>};</P>  
<P>&nbsp;</P></FONT>  
<P></P>  
<P><FONT color=#008000 size=2><FONT color=#008000 size=2>//synchronize the input   
date if set with the picker one   
<P>&nbsp;</P>  
<P>&nbsp;</P>  
<P>&nbsp;</P></FONT>  
<P>&nbsp;</P></FONT>  
<P></P>  
<P><FONT color=#0000ff size=2>var</FONT><FONT size=2> date =   
picker.get_selectedDate();   
<P>&nbsp;</P>  
<P>&nbsp;</P>  
<P>&nbsp;</P></FONT>  
<P></P>  
<P><FONT color=#0000ff size=2>if</FONT><FONT size=2> (date)   
<P>&nbsp;</P>  
<P>&nbsp;</P>  
<P>{</P>  
<P>calendar.get_focusedDate()[0] = date.getFullYear();</P>  
<P>calendar.get_focusedDate()[1] = date.getMonth() + 1;</P>  
<P>}</P>  
<P>$get(calendar._titleID).onclick(e);</P>  
<P>});</P>  
<P>fastNavigation.OnOK =</P>  
<P>&nbsp;</P></FONT>  
<P></P>  
<P><FONT color=#0000ff size=2>function</FONT><FONT size=2>()   
<P>&nbsp;</P>  
<P>&nbsp;</P>  
<P>{</P>  
<P>&nbsp;</P></FONT>  
<P></P>  
<P><FONT color=#0000ff size=2>var</FONT><FONT size=2> date = </FONT><FONT   
color=#0000ff size=2>new</FONT><FONT size=2> Date(fastNavigation.Year,   
fastNavigation.Month, 1);   
<P>&nbsp;</P>  
<P>&nbsp;</P>  
<P>picker.get_dateInput().set_selectedDate(date);</P>  
<P>fastNavigation.Popup.Hide();</P>  
<P>}</P>  
<P>&nbsp;fastNavigation.OnToday =</P>  
<P>&nbsp;</P></FONT>  
<P></P>  
<P><FONT color=#0000ff size=2>function</FONT><FONT size=2>()   
<P>&nbsp;</P>  
<P>&nbsp;</P>  
<P>&nbsp;{</P>  
<P>&nbsp;</P></FONT>  
<P></P>  
<P><FONT color=#0000ff size=2>var</FONT><FONT size=2> date = </FONT><FONT   
color=#0000ff size=2>new</FONT><FONT size=2> Date();   
<P>&nbsp;</P>  
<P>&nbsp;</P>  
<P>&nbsp;picker.get_dateInput().set_selectedDate(date);</P>  
<P>fastNavigation.Popup.Hide();</P>  
<P>}</P>  
<P>} </P>  
<P>&nbsp;</P></FONT>  
<P></P>  
<P><FONT color=#008000 size=2><FONT color=#008000 size=2>//Enable or disable   
datepicker based upon if they choose never expires or expires/renews   
<P>&nbsp;</P>  
<P>&nbsp;</P>  
<P>&nbsp;</P></FONT>  
<P>&nbsp;</P></FONT>  
<P></P>  
<P><FONT color=#0000ff size=2>function</FONT><FONT size=2>   
RadioButtonList1Change(){   
<P>&nbsp;</P>  
<P>&nbsp;</P>  
<P>&nbsp;</P></FONT>  
<P></P>  
<P><FONT color=#0000ff size=2>var</FONT><FONT size=2> rdlist =   
document.getElementById(</FONT><FONT color=#a31515 size=2>"&lt;%=   
RadioButtonList1.ClientID %&gt;"</FONT><FONT size=2>);   
<P>&nbsp;</P>  
<P>&nbsp;</P>  
<P>&nbsp;</P></FONT>  
<P></P>  
<P><FONT color=#0000ff size=2>var</FONT><FONT size=2> opt=   
rdlist.getElementsByTagName(</FONT><FONT color=#a31515   
size=2>'input'</FONT><FONT size=2>);   
<P>&nbsp;</P>  
<P>&nbsp;</P>  
<P>&nbsp;</P></FONT>  
<P></P>  
<P><FONT color=#0000ff size=2>var</FONT><FONT size=2> selected = </FONT><FONT   
color=#a31515 size=2>'empty'</FONT><FONT size=2>;   
<P>&nbsp;</P>  
<P>&nbsp;</P>  
<P>&nbsp;</P></FONT>  
<P></P>  
<P><FONT color=#0000ff size=2>for</FONT><FONT size=2>(</FONT><FONT color=#0000ff   
size=2>var</FONT><FONT size=2> i = 0; i &lt; opt.length ; i++){   
<P>&nbsp;</P>  
<P>&nbsp;</P>  
<P>&nbsp;</P></FONT>  
<P></P>  
<P><FONT color=#0000ff size=2>var</FONT><FONT size=2> rbRef = opt[i];   
<P>&nbsp;</P>  
<P>&nbsp;</P>  
<P>&nbsp;</P></FONT>  
<P></P>  
<P><FONT color=#0000ff size=2>if</FONT><FONT size=2> (rbRef.checked ==   
</FONT><FONT color=#0000ff size=2>true</FONT><FONT size=2>){   
<P>&nbsp;</P>  
<P>&nbsp;</P>  
<P>selected = rbRef.value;</P>  
<P>&nbsp;</P></FONT>  
<P></P>  
<P><FONT color=#0000ff size=2>break</FONT><FONT size=2>;   
<P>&nbsp;</P>  
<P>&nbsp;</P>  
<P>} </P>  
<P>}</P>  
<P>&nbsp;</P></FONT>  
<P></P>  
<P><FONT color=#0000ff size=2>var</FONT><FONT size=2> picker =   
$find(</FONT><FONT color=#a31515 size=2>"&lt;%= RadDatePicker1.ClientID   
%&gt;"</FONT><FONT size=2>);   
<P>&nbsp;</P>  
<P>&nbsp;</P>  
<P>&nbsp;</P></FONT>  
<P></P>  
<P><FONT color=#0000ff size=2>if</FONT><FONT size=2> (selected == </FONT><FONT   
color=#a31515 size=2>'1'</FONT><FONT size=2>){   
<P>&nbsp;</P>  
<P>&nbsp;</P>  
<P>picker.set_enabled(</P></FONT>  
<P></P>  
<P>&nbsp;</P>  
<P><FONT color=#0000ff size=2>true</FONT><FONT size=2>);   
<P>}</P>  
<P>&nbsp;</P></FONT>  
<P></P>  
<P><FONT color=#0000ff size=2>else</FONT><FONT size=2>{   
<P>&nbsp;</P>  
<P>&nbsp;</P>  
<P>&nbsp;</P></FONT>  
<P></P>  
<P><FONT color=#0000ff size=2>if</FONT><FONT size=2> (selected == </FONT><FONT   
color=#a31515 size=2>'empty'</FONT><FONT size=2>){   
<P>&nbsp;</P>  
<P>&nbsp;</P>  
<P>}</P>  
<P>&nbsp;</P></FONT>  
<P></P>  
<P><FONT color=#0000ff size=2>else</FONT><FONT size=2>{   
<P>&nbsp;</P>  
<P>&nbsp;</P>  
<P>picker.set_enabled(</P></FONT>  
<P></P>  
<P>&nbsp;</P>  
<P><FONT color=#0000ff size=2>false</FONT><FONT size=2>);   
<P>} </P>  
<P>}</P>  
<P>}</P>  
<P>&nbsp;</P></FONT>  
<P></P>  
<P><FONT color=#0000ff size=2>&lt;/</FONT><FONT color=#a31515   
size=2>script</FONT><FONT color=#0000ff size=2><FONT color=#0000ff size=2>&gt;   
<P>&nbsp;</P>  
<P>&nbsp;</P>  
<P>&nbsp;</P></FONT>  
<P>&nbsp;</P></FONT>  
<P></P>  
<P><FONT color=#0000ff size=2><BR>&lt;</FONT><FONT color=#a31515   
size=2>asp</FONT><FONT color=#0000ff size=2>:</FONT><FONT color=#a31515   
size=2>RadioButtonList</FONT><FONT size=2> </FONT><FONT color=#ff0000   
size=2>ID</FONT><FONT color=#0000ff size=2>="RadioButtonList1"</FONT><FONT   
size=2> </FONT><FONT color=#ff0000 size=2>runat</FONT><FONT color=#0000ff   
size=2>="server"</FONT><FONT size=2> </FONT><FONT color=#ff0000   
size=2>onclick</FONT><FONT color=#0000ff size=2><FONT color=#0000ff   
size=2>="RadioButtonList1Change()"&gt;   
<P>&nbsp;</P>  
<P style="MARGIN: 0in 0in 0pt">&nbsp;</P>  
<P>&nbsp;</P>  
<P>&nbsp;</P></FONT>  
<P>&nbsp;</P></FONT>  
<P></P>  
<P><FONT color=#0000ff size=2>&lt;</FONT><FONT color=#a31515   
size=2>asp</FONT><FONT color=#0000ff size=2>:</FONT><FONT color=#a31515   
size=2>ListItem</FONT><FONT size=2> </FONT><FONT color=#ff0000   
size=2>Value</FONT><FONT color=#0000ff size=2>="0"&gt;</FONT><FONT size=2>Never   
Expires</FONT><FONT color=#0000ff size=2>&lt;/</FONT><FONT color=#a31515   
size=2>asp</FONT><FONT color=#0000ff size=2>:</FONT><FONT color=#a31515   
size=2>ListItem</FONT><FONT color=#0000ff size=2><FONT color=#0000ff size=2>&gt;   
 
<P>&nbsp;</P>  
<P>&nbsp;</P>  
<P>&nbsp;</P></FONT>  
<P>&nbsp;</P></FONT>  
<P></P>  
<P><FONT color=#0000ff size=2>&lt;</FONT><FONT color=#a31515   
size=2>asp</FONT><FONT color=#0000ff size=2>:</FONT><FONT color=#a31515   
size=2>ListItem</FONT><FONT size=2> </FONT><FONT color=#ff0000   
size=2>Selected</FONT><FONT color=#0000ff size=2>="True"</FONT><FONT size=2>   
</FONT><FONT color=#ff0000 size=2>Value</FONT><FONT color=#0000ff   
size=2>="1"&gt;</FONT><FONT size=2>Expires/Renews after the close of :   
</FONT><FONT color=#0000ff size=2>&lt;/</FONT><FONT color=#a31515   
size=2>asp</FONT><FONT color=#0000ff size=2>:</FONT><FONT color=#a31515   
size=2>ListItem</FONT><FONT color=#0000ff size=2><FONT color=#0000ff size=2>&gt;   
 
<P>&nbsp;</P>  
<P>&nbsp;</P>  
<P>&nbsp;</P></FONT>  
<P>&nbsp;</P></FONT>  
<P></P>  
<P><FONT color=#0000ff size=2>&lt;/</FONT><FONT color=#a31515   
size=2>asp</FONT><FONT color=#0000ff size=2>:</FONT><FONT color=#a31515   
size=2>RadioButtonList</FONT><FONT color=#0000ff size=2><FONT color=#0000ff   
size=2>&gt;   
<P>&nbsp;</P>  
<P>&nbsp;</P>  
<P>&nbsp;</P></FONT>  
<P>&nbsp;</P></FONT>  
<P></P>  
<P><FONT color=#0000ff size=2><BR>&lt;</FONT><FONT color=#a31515   
size=2>telerik</FONT><FONT color=#0000ff size=2>:</FONT><FONT color=#a31515   
size=2>RadDatePicker</FONT><FONT size=2> </FONT><FONT color=#ff0000   
size=2>ID</FONT><FONT color=#0000ff size=2>="RadDatePicker1"</FONT><FONT size=2>   
</FONT><FONT color=#ff0000 size=2>runat</FONT><FONT color=#0000ff   
size=2>="server"</FONT><FONT size=2> </FONT><FONT color=#0000ff size=2><FONT   
color=#0000ff size=2>&gt;   
<P>&nbsp;</P>  
<P style="MARGIN: 0in 0in 0pt">&nbsp;</P>  
<P>&nbsp;</P>  
<P>&nbsp;</P></FONT>  
<P>&nbsp;</P></FONT>  
<P></P>  
<P><FONT color=#0000ff size=2>&lt;</FONT><FONT color=#a31515   
size=2>DateInput</FONT><FONT size=2> </FONT><FONT color=#ff0000   
size=2>DateFormat</FONT><FONT color=#0000ff size=2>="MMMM yyyy"</FONT><FONT   
size=2> </FONT><FONT color=#ff0000 size=2>runat</FONT><FONT color=#0000ff   
size=2><FONT color=#0000ff size=2>="server"&gt;   
<P>&nbsp;</P>  
<P>&nbsp;</P>  
<P>&nbsp;</P></FONT>  
<P>&nbsp;</P></FONT>  
<P></P>  
<P><FONT color=#0000ff size=2>&lt;/</FONT><FONT color=#a31515   
size=2>DateInput</FONT><FONT color=#0000ff size=2><FONT color=#0000ff   
size=2>&gt;   
<P>&nbsp;</P>  
<P>&nbsp;</P>  
<P>&nbsp;</P></FONT>  
<P>&nbsp;</P></FONT>  
<P></P>  
<P><FONT color=#0000ff size=2>&lt;/</FONT><FONT color=#a31515   
size=2>telerik</FONT><FONT color=#0000ff size=2>:</FONT><FONT color=#a31515   
size=2>RadDatePicker</FONT><FONT color=#0000ff size=2><FONT color=#0000ff   
size=2>&gt;   
<P>&nbsp;</P>  
<P>&nbsp;</P>  
<P>&nbsp;</P></FONT>  
<P>&nbsp;</P></FONT>  
<P></P>  
<P><FONT color=#0000ff size=2>&lt;/</FONT><FONT color=#a31515   
size=2>div</FONT><FONT color=#0000ff size=2><FONT color=#0000ff size=2>&gt;   
<P>&nbsp;</P>  
<P>&nbsp;</P>  
<P>&nbsp;</P></FONT>  
<P>&nbsp;</P></FONT>  
<P></P>  
<P><FONT color=#0000ff size=2>&lt;/</FONT><FONT color=#a31515   
size=2>form</FONT><FONT color=#0000ff size=2><FONT color=#0000ff size=2>&gt;   
<P>&nbsp;</P>  
<P>&nbsp;</P>  
<P>&lt;/</P></FONT>  
<P>&nbsp;</P></FONT>  
<P></P>  
<P><FONT color=#a31515 size=2>body</FONT><FONT color=#0000ff size=2><FONT   
color=#0000ff size=2>&gt;   
<P>&nbsp;</P>  
<P>&nbsp;</P>  
<P>&lt;/</P></FONT>  
<P>&nbsp;</P></FONT>  
<P></P>  
<P><FONT color=#a31515 size=2>html</FONT><FONT color=#0000ff size=2><FONT   
color=#0000ff size=2>&gt; </FONT></FONT></P> 

 

 

 

 

 

 

 

 

 

 

 

 

 

I am using 2008.1.515.20 version of RadDatePicker Control.

Please help me to fix/solve this.

Thanks in advance,

Igor.

 

 

 

 

 

 

 

 

3 Answers, 1 is accepted

Sort by
0
Pavlina
Telerik team
answered on 11 Aug 2009, 02:48 PM
Hi Igor,

To enable or disable a RadDatePicker control, you need to call the set_enabled(true/false) client-side method of the Picker client-side object. Please find more information in the following help article:
Client-Side Basics (Enabling and disabling the RadDatePicker ........  section)

I hope this helps.

Sincerely yours,

Pavlina
the Telerik team

 


Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.
0
Igor Koretsky
Top achievements
Rank 1
answered on 17 Aug 2009, 02:42 PM

Pavlina,

Thanks for reply.

I am using set_enabled(true/false) to enable/disable RadDatePicker.

My problem is that I am getting an error when I am using this method on RadDatePicker with custom implementation found here:

http://www.telerik.com/community/code-library/submission/b311D-mdkhb.aspx.
Please, try the code sample that I posted (just the top code block).   

Igor.
  

0
Accepted
Martin
Telerik team
answered on 19 Aug 2009, 03:18 PM
Hello Igor,

The following modification on the code run as expected on my side:
  • remove the RadioButtonList and its functionality for clarity.
  • add a button performing the enable / disable functionality like this:
<input type="button" value="Enable / Disable" id="Button1" onclick="Toggle()" /> 

  • add the following client side function:
function Toggle(sender, args) 
            { 
                var picker = $find("<%= RadDatePicker1.ClientID %>"); 
picker.get_dateInput().set_enabled(!picker.get_dateInput().get_enabled()); 
                if (!picker.get_dateInput().get_enabled()) 
                { 
                    picker.get_popupButton().style.display = "none"
                    picker.get_dateInput().disable(); 
                } 
                else 
                { 
                    picker.get_popupButton().style.display = "block"
                    picker.get_dateInput().enable(); 
                } 
            } 

I hope this helps.

Greetings,
Martin
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.
Tags
Calendar
Asked by
Igor Koretsky
Top achievements
Rank 1
Answers by
Pavlina
Telerik team
Igor Koretsky
Top achievements
Rank 1
Martin
Telerik team
Share this question
or