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

Newest RadDatePicker crashes code (broken functionality)

5 Answers 78 Views
Calendar
This is a migrated thread and some comments may be shown as answers.
Jeremy Yoder
Top achievements
Rank 1
Jeremy Yoder asked on 27 Jun 2012, 04:34 PM

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.

5 Answers, 1 is accepted

Sort by
0
Vasil
Telerik team
answered on 02 Jul 2012, 11:19 AM
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.
0
Jeremy Yoder
Top achievements
Rank 1
answered on 02 Jul 2012, 01:28 PM

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 
0
Vasil
Telerik team
answered on 05 Jul 2012, 11:52 AM
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.
0
Jeremy Yoder
Top achievements
Rank 1
answered on 05 Jul 2012, 02:37 PM

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.)
0
Jeremy Yoder
Top achievements
Rank 1
answered on 04 Sep 2012, 01:06 PM

BTW, forgot to mention thanks for the fix, which works great. We very much appreciate your support!
Tags
Calendar
Asked by
Jeremy Yoder
Top achievements
Rank 1
Answers by
Vasil
Telerik team
Jeremy Yoder
Top achievements
Rank 1
Share this question
or