How to assign variable to $find function

4 posts, 0 answers
  1. Allen
    Allen avatar
    111 posts
    Member since:
    Apr 2012

    Posted 04 Jan 2013 Link to this post

    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");
    but I receive error "
    Microsoft JScript runtime error: Object doesn't support property or method 'set_enabled".
  2. Kevin
    Kevin avatar
    360 posts
    Member since:
    Jul 2012

    Posted 05 Jan 2013 Link to this post

    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.
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Allen
    Allen avatar
    111 posts
    Member since:
    Apr 2012

    Posted 07 Jan 2013 Link to this post

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


    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");
                   = "visible";
                   = "visible";
                            var baseIdStart = "<%= RadDateTimePickerSundayStart.ClientID %>";
                            var timePickerStart = $find(baseIdStart.replace("Sunday", optionDate));
                            var baseIdEnd = "<%= RadDateTimePickerMondayEnd.ClientID %>";
                            var timePickerEnd = $find(baseIdEnd.replace("Sunday", optionDate));

                            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;

  5. Marin Bratanov
    Marin Bratanov avatar
    3602 posts

    Posted 09 Jan 2013 Link to this post

    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:

    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.
Back to Top