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

How to assign variable to $find function

3 Answers 75 Views
Window
This is a migrated thread and some comments may be shown as answers.
Allen
Top achievements
Rank 1
Allen asked on 04 Jan 2013, 09:15 PM
Is there a way to assign variable to $find function?
eg: It can be Sunday thru Saturday
var dateOfWeek = "Wednesday"
var timePickerStart = $find("<%= RadDateTimePickerWednesdayStart.ClientID %>");

or I can use:
var timePickerStart2 = document.getElementById("ctl00_TabContent_RadWindow1_C_RadDateTimePicker" + dateOfWeek + "Start");
timePickerStart2.set_enabled(true);
but I receive error "
Microsoft JScript runtime error: Object doesn't support property or method 'set_enabled".

3 Answers, 1 is accepted

Sort by
0
Kevin
Top achievements
Rank 2
answered on 05 Jan 2013, 03:37 PM
Hello Allen,

I'm assuming you have a RadTimePicker for each day of the week. If so, you can change the id by doing this:
var dateOfWeek = "Wednesday";
var baseId = "<%= RadDateTimePickerMondayStart.ClientID %>";
var timePickerStart = $find(baseId.replace("Monday",dayOfWeek));

This assumes that they all follow the same naming convention.

I hope that helps.
0
Allen
Top achievements
Rank 1
answered on 07 Jan 2013, 07:25 PM

on the VB.net side the following code only produce the date ("2013-1-30"), no time.  It's suposed to produce "2013-1-30-18-00-00":  
SelectedDateEnd

 

Dim SelectedDateEnd as Date = RadDateTimePickerWednesdayEnd.DateInput.SelectedDate.Value
My aspx page look like:

 

var timeViewStart = document.getElementById("ctl00_TabContent_RadWindow1_C_RadDateTimePicker" + dateOfWeek + "Start_dateInput_display");
                        var timeViewEnd = document.getElementById("ctl00_TabContent_RadWindow1_C_RadDateTimePicker" + dateOfWeek + "End_dateInput_display");
                        var timeViewStartWrapper = document.getElementById("ctl00_TabContent_RadWindow1_C_RadDateTimePicker" + dateOfWeek + "Start_wrapper");
                        var timeViewEndWrapper = document.getElementById("ctl00_TabContent_RadWindow1_C_RadDateTimePicker" + dateOfWeek + "End_wrapper");
                        timeViewStartWrapper.style.visibility = "visible";
                        timeViewEndWrapper.style.visibility = "visible";
                        var baseIdStart = "<%= RadDateTimePickerSundayStart.ClientID %>";
                        var timePickerStart = $find(baseIdStart.replace("Sunday", optionDate));
                        var baseIdEnd = "<%= RadDateTimePickerMondayEnd.ClientID %>";
                        var timePickerEnd = $find(baseIdEnd.replace("Sunday", optionDate));

                        timePickerStart.set_enabled(true);
                        timePickerEnd.set_enabled(true);
                        if (null != timeViewStart) {
                            timeViewStart.innerHTML = "12:00 A";
                            timeViewEnd.innerHTML = "6:00 P";
                            var timeViewStartValue = document.getElementById("ctl00_TabContent_RadWindow1_C_RadDateTimePicker" + dateOfWeek + "Start_dateInput");
                            var timeViewEndValue = document.getElementById("ctl00_TabContent_RadWindow1_C_RadDateTimePicker" + dateOfWeek + "End_dateInput");
                            var date = timeViewEndValue.getAttribute('value');
                            var dateSubstring
                            var dateStringOnly = DateWednesday.format("yyyy-mm-dd");
                            if (date != null) {
                                dateSubstring = date.substring(0, 11);
                            }
                            else {
                                dateSubstring = dateStringOnly;

                            }

                            timeViewStartValue.setAttribute("value", dateSubstring + "00-00-00");
                            timeViewEndValue.setAttribute("value", dateSubstring + "18-00-00");
                            timeViewStart.disabled = true;
                            timeViewEnd.disabled = true;
                        }

0
Marin Bratanov
Telerik team
answered on 09 Jan 2013, 01:53 PM
Hello Allen,

When working with RadControls on the client you should use their client-side API instead of only attributes of the pure HTML elements. This is needed because there is a lot of code working behind the public API we provide. The list with the RadDatePicker's client-side API is available here: http://www.telerik.com/help/aspnet-ajax/calendar-client-side-rad-datepicker.html.


All the best,
Marin Bratanov
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
Window
Asked by
Allen
Top achievements
Rank 1
Answers by
Kevin
Top achievements
Rank 2
Allen
Top achievements
Rank 1
Marin Bratanov
Telerik team
Share this question
or