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

disable telerik raddatepicker

1 Answer 365 Views
Calendar
This is a migrated thread and some comments may be shown as answers.
Santosh
Top achievements
Rank 1
Santosh asked on 01 Oct 2013, 11:05 AM
how to disable/enable telerik raddatepicker using javascript ????

1 Answer, 1 is accepted

Sort by
0
Accepted
Shinu
Top achievements
Rank 1
answered on 03 Oct 2013, 03:18 AM
Hi Santosh,

Please have a look into the following JavaScript that I tried to enable/disable RadDatePicker in OnClientClicked event of RadButton.

ASPX:
<telerik:RadDatePicker ID="RadDatePicker1" runat="server">
</telerik:RadDatePicker>
<telerik:RadButton ID="RadButton1" runat="server" Text="Enable/Disable DatePicker"
    AutoPostBack="false" OnClientClicked="OnClientClicked1">
</telerik:RadButton>

JavaScript:
<script type="text/javascript">
    function OnClientClicked1(sender, args) {
        var datepicker = $find("<%=RadDatePicker1.ClientID %>");
        if (datepicker.get_enabled() == false)
            datepicker.set_enabled(true);
        else
            datepicker.set_enabled(false);
    }
</script>

Thanks,
Shinu.
Arumugam
Top achievements
Rank 1
commented on 08 Dec 2021, 05:02 AM

I am trying the same but not working. but one different is I am using Master page. So any other ideas appreciated!
Doncho
Telerik team
commented on 08 Dec 2021, 02:07 PM

Arumugam,

The approach when a Master page is used, should not be much different.
A possible problem in such a scenario could be the server expression for getting a reference to the RadDatePicker (<%= %>). The server expression can only be used when the script and the DatePicker declaration reside on the same aspx page.

In any other case you can use another approach to get a reference to the RadDatePicker client-side object. Check out different ways to Get Client-side Reference to a Control Object.

For instance, you can try the following:
JavaScript

function OnClientClicked1(sender, args) {
    var datepicker = $telerik.findControl(document,"RadDatePicker1");
    if (datepicker.get_enabled() == false)
        datepicker.set_enabled(true);
    else
        datepicker.set_enabled(false);
}

ASPX

<telerik:RadDatePicker ID="RadDatePicker1" runat="server">
</telerik:RadDatePicker>
<telerik:RadButton ID="RadButton1" runat="server" Text="Enable/Disable DatePicker"
    AutoPostBack="false" OnClientClicked="OnClientClicked1">
</telerik:RadButton>
If this is not the case please share some more information about the current case so we can assist more accurately.

Tags
Calendar
Asked by
Santosh
Top achievements
Rank 1
Answers by
Shinu
Top achievements
Rank 1
Share this question
or