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

[Solved] eventArgs.get_newStartTime() format issue

2 Answers 144 Views
Scheduler
This is a migrated thread and some comments may be shown as answers.
Joe
Top achievements
Rank 1
Joe asked on 29 Jun 2008, 11:23 PM
I have this property of the RadScheduler:  OnClientAppointmentMoveEnd="AppointmentMoveEnd", below is the javascript for the function.  It fires after you move an appointment in the scheduler.

<telerik:RadScriptBlock ID="RadScriptBlock1" runat="server">
           <script type="text/javascript">
               
                function AppointmentMoveEnd(sender, eventArgs)
                {
                    var ajaxManager = $find("<%=RadAjaxManager1.ClientID%>");
                    var apt = eventArgs.get_appointment();
                    var newStartTime = eventArgs.get_newStartTime();
                    alert(newStartTime);

                     ajaxManager.ajaxRequest(newStartTime);

                }
           </script>
       </telerik:RadScriptBlock>

So looking at this line above (ajaxManager.ajaxRequest(newStartTime);) - this calls my C# server side code, in there I try to convert newStartTime to a .NET DateTime object, but the string looks like this:

"Sun Jun 29 2008 09:00:00 GMT-0500 (Central Daylight Time)"

- the above does not convert to a DateTime object (using Convert.ToDateTime()).  I could obviously manipulate this with javascript to work, but is there somethign built in that i can use?  RadControls are developed for .NET code, you think it would convert to a .NET convertable string object.  It would probably work if the 'Sun' part was not there.   Thank you

2 Answers, 1 is accepted

Sort by
0
T. Tsonev
Telerik team
answered on 30 Jun 2008, 08:55 AM
Hello Joe,

In fact the property returns a Date object, so it is up to the browser to decide how to convert it to a string. You can use the following code from our RadWindow integration example:

function formatDate(date) 
    var year = padNumber(date.getFullYear(), 4); 
    var month = padNumber(date.getMonth() + 1, 2); 
    var day = padNumber(date.getDate(), 2); 
    var hour = padNumber(date.getHours(), 2); 
    var minute = padNumber(date.getMinutes(), 2); 
     
    return year + month + day + hour + minute; 

Then on the server:

DateTime.ParseExact(jsTime, "yyyyMMddHHmm"null); 

I hope this helps.

Greetings,
Tsvetomir Tsonev
the Telerik team

Instantly find answers to your questions at the new Telerik Support Center
0
Joe
Top achievements
Rank 1
answered on 30 Jun 2008, 12:37 PM
Ah of course, i was already using that javascript a couple lines above, for inserting and editing appointments.  Maybe thats why people usually dont work on sundays.  thank you

Tags
Scheduler
Asked by
Joe
Top achievements
Rank 1
Answers by
T. Tsonev
Telerik team
Joe
Top achievements
Rank 1
Share this question
or