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

Make DatePicker ReadOnly Without Fuzzy

1 Answer 62 Views
Input
This is a migrated thread and some comments may be shown as answers.
Velma
Top achievements
Rank 1
Velma asked on 05 Jan 2012, 08:55 PM
I made the following Javascript function which successfully makes the DatePicker  readonly (including no select from the calendar) without the grey fuzzy appearance. (I think it might be possible to do this with CSS, not sure, but we are in IE, where that doesn't work.) I don't know if this is the best approach, but it works fine. I think it's a common need, and I couldn't find it documented anywhere, so I'm posting it here in case others can use it. Function also supports making editable again.

function SetDatePickerReadOnly(picker, readOnly) {
    picker.set_enabled(!readOnly);  // disable the overall control if readOnly is true (or the converse)
    var input = picker.get_dateInput();  //retrieves the inner DateInput portion of the DatePicker
    input.enable(); // enable the input box only, leaving the calendar disabled (or the converse)
    input._textBoxElement.readOnly = readOnly;  //the inner reference to the input object; changes appearance to "ReadOnly" style and not editable
    // (or the converse)
}

Usage:
var dobPicker = $find("<%= DateOfBirthDatePicker.ClientID %>");
SetDatePickerReadOnly(dobPicker, true);


1 Answer, 1 is accepted

Sort by
0
Accepted
Maria Ilieva
Telerik team
answered on 06 Jan 2012, 04:15 PM
Hi,


Thank you for sharing your approach with the community. I'm sure it will be helpful for the other users which need this functionality.


Greetings,
Maria Ilieva
the Telerik team
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now
Tags
Input
Asked by
Velma
Top achievements
Rank 1
Answers by
Maria Ilieva
Telerik team
Share this question
or