Newest RadDatePicker crashes code (broken functionality)

6 posts, 0 answers
  1. Jeremy Yoder
    Jeremy Yoder avatar
    131 posts
    Member since:
    Dec 2009

    Posted 27 Jun 2012 Link to this post


    I upgrade to the latest version of Telerik (2012.2.607.40) and now my code no longer works. My control is below...

    <telerik:RadDatePicker ID="RadDatePicker1" runat="server" Culture="English (United States)" >
        <Calendar UseRowHeadersAsSelectors="False" UseColumnHeadersAsSelectors="False" ViewSelectorText="x" ShowRowHeaders="false">
            <SpecialDays>
                <telerik:RadCalendarDay Repeatable="Today" ItemStyle-BorderColor="Blue">
                </telerik:RadCalendarDay>
            </SpecialDays>
        </Calendar>
        <DatePopupButton HoverImageUrl="" ImageUrl="" ToolTip="Calendar Search" />
        <DateInput ID="DateInput1" runat="server" DateFormat="MM/yyyy"
            DisplayDateFormat="MM/yyyy">
            <ClientEvents OnFocus="Focus" OnBlur="Blur" OnValueChanging="ValueChanging" OnValueChanged="ValueChanged">
            </ClientEvents>
        </DateInput>
    </telerik:RadDatePicker>


    This is the start of my ValueChanging function...

    function ValueChanging(sender, args) {
     
        var enteredValue = args.get_newValue(); //Retrieves value as string entered or selected in calendar.
        enteredValue = enteredValue.replace(/-/g, '/'); // In case user enters hyphen, change it to backslash.

    After selecting a date from the calendar, the code now crashes on the replace function because get_newValue returns Wed Jun 6 00:00:00 CDT 2012, which is not a string, so it doesn't have a replace function. This used to work. Also, while digging for answers at the link below, I tried get_newDate() which I would expect to return that value instead, but it is now undefined and no longer a valid function.
  2. Vasil
    Admin
    Vasil avatar
    1547 posts

    Posted 02 Jul 2012 Link to this post

    Hello Jeremy,

    You could use this code under the declaration of your ScriptManager to achieve the same functionality:
    if (Telerik.Web.UI.RadDateInput)
    {  
    Telerik.Web.UI.RadDateInput.prototype.set_value = function (newRowValue)
        {
            newRowValue = newRowValue.replace(/-/g, '/');
     
            var newValue =  this.parseDate(newRowValue) || newRowValue;
            Telerik.Web.UI.RadDateInput.callBaseMethod(this, 'set_value', [newValue]);
        }
    }


    All the best,
    Vasil
    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.
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Jeremy Yoder
    Jeremy Yoder avatar
    131 posts
    Member since:
    Dec 2009

    Posted 02 Jul 2012 Link to this post


    I don't even know what you mean by that. My code is in an ascx file, so it's a control used throughout the website and in other websites. The control does not contain a ScriptManager, so even if your solution could work, I'd have to add it to every page that ever used my control. That defeats the purpose of creating a control, which should be self-contained.

    I assumed you accidentally changed the functionality since it no longer does what your help link down below says. Does this mean you're permanently changing the functionality? If you are arbitrarily changing things in your controls, this is disturbing since we are heavily reliant on your control throughout our projects.

    All I want is to retrieve the text value of the RadDatePicker within the ValueChanging event. That seems like it should be pretty straight forward and self contained within the control. So please offer me another solution, even if it's waiting for your next release to put this functionality back into your control, just as your documentation says it should do.

    http://www.telerik.com/help/aspnet-ajax/calendar-on-date-selected.html 
  5. Vasil
    Admin
    Vasil avatar
    1547 posts

    Posted 05 Jul 2012 Link to this post

    Hi Jeremy,

    Calendar's OnDateSelected is different from the input's onValueChanging. However I see that the arguments in the onValueChanging events holds date object instead of string one, and this will be corrected in the next Hotfix on Tuesday 10th of June.

    Kind regards,
    Vasil
    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.
  6. Jeremy Yoder
    Jeremy Yoder avatar
    131 posts
    Member since:
    Dec 2009

    Posted 05 Jul 2012 Link to this post


    Awesome, thanks. Look forward to seeing it in 5 days. If it helps, we were told to do all this from this post here...

    http://www.telerik.com/community/forums/aspnet-ajax/calendar/datepicker-format-issue.aspx 

    In short, we always want the input to display in the format of MM/yyyy, after the user uses the date selector or types an entry. So the user can type 6/12, and within OnValueChanging, I read that from get_newValue (string) then parse it to a valid date which I assign to the control via set_newValue, yet continue to display it as entered. (Or I'll cancel it via CancelNewValue if the entered value is invalid.)
  7. Jeremy Yoder
    Jeremy Yoder avatar
    131 posts
    Member since:
    Dec 2009

    Posted 04 Sep 2012 Link to this post


    BTW, forgot to mention thanks for the fix, which works great. We very much appreciate your support!
Back to Top
UI for ASP.NET Ajax is Ready for VS 2017