RadDatePicker and custom attributes

2 posts, 1 answers
  1. Paul Evers
    Paul Evers avatar
    52 posts
    Member since:
    Oct 2011

    Posted 04 Apr Link to this post

    I have a RadDatePicker where I have a custom attribute

    <telerik:RadDatePicker ID="RadDatePicker_MinDate" runat="server" AutoPostBack="false" CssClass="InputDateField" variable="mindate">
        <ClientEvents OnPopupOpening="DatePickerOnFocus"
                               OnDateSelected="RadDatePicker_MinDate_DateSelected" />
        <DateInput runat="server"
              ClientEvents-OnFocus="DatePickerOnFocus">
        </DateInput>
    </telerik:RadDatePicker>

    The clientside function DatePickerOnFocus:

    function DatePickerOnFocus(sender, eventArgs) {
            var id = sender.get_element().id + "_wrapper";
            var wrapper = $get(id);
            var var1 = wrapper.getAttribute("variable");
            .......
    }

    This works fine for the event OnPopupOpening.

    For the event ClientEvents-OnFocus (of the DateInput) this doesn't work. I get a null value when reading the custom attribute.

    How can I get the custom attribute in the event ClientEvents-OnFocus of the DateInput?

     

    Paul

  2. Answer
    Viktor Tachev
    Admin
    Viktor Tachev avatar
    1488 posts

    Posted 04 Apr Link to this post

    Hello Paul,

    The behavior you are observing is expected. Note that the sender is different in the two events.

    When the OnPopupOpening event is handled the sender represents the client-side object of RadDatePicker.

    When the DateInput-ClientEvents-OnFocus event is handled the sender is actually a DateInput object.

    In order to retrieve the custom attribute consistently you need to ensure that you get reference of the RadDatePicker element.

    Try to use the modified code below and let me know how it works.


    function DatePickerOnFocus(sender, args) {
        var id = sender.get_element().id.replace("_dateInput", "") + "_wrapper";
        var wrapper = $get(id);
        var var1 = wrapper.getAttribute("variable");
     
    }


    Regards,
    Viktor Tachev
    Telerik
    Do you need help with upgrading your ASP.NET AJAX, WPF or WinForms projects? Check the Telerik API Analyzer and share your thoughts.
  3. UI for ASP.NET Ajax is Ready for VS 2017
Back to Top