This is a migrated thread and some comments may be shown as answers.
ModifiedAppointment Values
9 Answers 105 Views
This is a migrated thread and some comments may be shown as answers.
Michael J.
Top achievements
Rank 1
Michael J. asked on 27 Apr 2009, 07:30 PM
Im working with the RAD Scheduler control.  I've declared a RAD Scheduler control on my ASPX page, and it's OnAppointmentUpdate attribute is as follows:

OnAppointmentUpdate="RadScheduler1_AppointmentUpdate"

In the code-behind, the event handler is defined as follows:

protected void RadScheduler1_AppointmentUpdate(object sender, AppointmentUpdateEventArgs e)
{
    //CODE
}


Documentation says that by referencing e.ModifiedAppointment, I should be able to access the new Appointment values I've entered right before they're inserted into the database.

But -- These values are the same as the original Appointment object!  It appears as though any new values are not accessible via the e.ModifiedAppointment object.

Any ideas what's going on?  Seems easy, but I'm stumped!

TIA!
Mike

 

9 Answers, 1 is accepted

Sort by
0
Michael J.
Top achievements
Rank 1
answered on 28 Apr 2009, 03:35 PM
Anyone?
0
Genady Sergeev
Telerik team
answered on 30 Apr 2009, 08:44 AM
Hello Michael J.,

This is strange issue, does the following code returns the same values after a modify to an appointment?

 protected void RadScheduler1_AppointmentUpdate(object sender, AppointmentUpdateEventArgs e) 
    { 
        string originalAppointment = e.Appointment.Subject; 
        string modifiedAppointment = e.ModifiedAppointment.Subject; 
    } 


Best wishes,
Genady Sergeev
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.
0
Michael J.
Top achievements
Rank 1
answered on 30 Apr 2009, 01:03 PM
Genady,

When the following event handler is invoked:

 protected void RadScheduler1_AppointmentUpdate(object sender, AppointmentUpdateEventArgs e) 
    { 
        string originalAppointment = e.Appointment.Subject; 
        string modifiedAppointment = e.ModifiedAppointment.Subject; 
    } 

...the values of originalAppointment and modifiedAppointment are the same.

The application is smart enough to understand on the server side that an update is taking place.  However, the argument values containted in "e" are not updated with the latest changes from the screen. 

Any ideas?

Thanks,
Mike
0
Michael J.
Top achievements
Rank 1
answered on 30 Apr 2009, 02:53 PM
Problem solved, although it doesn't make much sense to me up front.

I configured a new RAD Scheduler object on my ASPX page and set it's attributes appropriately.  Although the attributes are the same as those in my prior RAD Scheduler, the AppointmentUpdate's e.ModifiedAppointment object is now being passed the correct updated Appointment values from the screen.

Hope this helps,

Mike
0
rjb227s
Top achievements
Rank 1
answered on 18 Jan 2010, 04:55 PM
Genady,

I am having this same issue and the solution below was unfortunately not a helpful answer.  I have spent so many hours on this I have lost count. 

When dragging and dropping an appointment, the AppointmentUpdate Server event has the same value for the event args for the e.Appointment AND e.ModifiedAppointment.  When I add the client event OnClientAppointmentMoveEnd, I get the correct modified value on the client side, but the serverside is always wrong.

[.net 2.0 + Q3 2009 with hotfix]

Thanks for the help,

Ryan (Code Below)

Server Code: (values for e.Appointment and e.ModifiedAppointment are the same)
protected void CalendarRadScheduler_AppointmentUpdate(object sender, AppointmentUpdateEventArgs e) 
        { 
            if (e.Appointment.Start != e.ModifiedAppointment.Start) 
            { 
                Appointment objModApt = e.ModifiedAppointment; 
 
                //load message from database 
                MessageDAO daoMessage = new MessageDAO(); 
                MessageDTO dtoMessage = daoMessage.GetById((int)objModApt.ID); 
 
                //update message with new time 
                dtoMessage.Start = objModApt.Start; 
                dtoMessage.End = objModApt.Start.AddMinutes(10); 
 
                //Save updated message to database 
                dtoMessage.Method = CoreToolkit.ObjectMethod.Modify; 
                daoMessage.Save(dtoMessage); 
            } 
            else 
            { 
                e.Cancel = true
            } 
        } 

Client Code:
<%@ Control Language="C#" AutoEventWireup="true" Codebehind="MyUserControl.ascx.cs"  
    Inherits="UserControls.MyUserControl" %>  
<meta http-equiv="X-UA-Compatible" content="IE=7"/>  
  
<pro:RadCodeBlock ID="RadCodeBlock1" runat="server">  
  
<script type="text/javascript"


 function OnClientAppointmentMoveEnd(sender, eventArgs)
           {
            alert("New start time: " + eventArgs.get_newStartTime());
           }
                        
  
            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;  
            }  
              
            function padNumber(number, totalDigits)  
            {  
                numbernumbernumber = number.toString();  
                var padding = '';  
                if (totalDigits > number.length)  
                {  
                    for (i = 0; i < (totalDigits - number.length); i++)  
                    {  
                        padding += '0';  
                    }  
                }  
                  
                return padding + number.toString();  
            }  
                  
            //prevent resizing  
          function OnClientAppointmentResizeStart(sender, eventArgs)  
          {  
             alert('no resizing');  
             //eventArgs.set_cancel(true);  
          }  
              
            //prevent resizing  
          function OnClientAppointmentResizeEnd(sender, eventArgs)  
          {           
            alert('resizing end')                           
          }  
            
          //prevent editing of recurring messages  
          function OnClientAppointmentEditing(sender, eventArgs)  
          {  
            alert('editing');  
            if(eventArgs.get_editingRecurringSeries())  
                  eventArgs.set_cancel(true);  
          }  
            
          function OnClientAppointmentDoubleClick(sender, eventArgs)  
          {  
              alert('here');  
          }  
            
          function OnClientAppointmentInserting(sender, eventArgs)  
            {  
                 var start = formatDate(eventArgs.get_startTime());  
                   
                 document.location.href = '<%=PageToRedirect + "?StartDate="%>' + start;  
                 eventArgs.set_cancel(true);  
            }    
              
    </script>  
  
</pro:RadCodeBlock>  
<telerik:RadScriptBlock runat="server" ID="scriptContextMenu">  
  
        <script type="text/javascript">  
            var selectedAppointment = null;  
            var contextMenuSlot = null;  
  
            function checkResourceMenuItem(menu, appointment) {  
                var calendar = appointment.get_resources().getResourcesByType("Calendar").getResource(0);  
                if (!calendar)  
                    return;  
  
                var actionItem = menu.findItemByText("Action");  
                //Traverse all menu items below "Action"  
                for (var i = 0; i < actionItem.get_items().get_count(); i++) {  
                    var item = actionItem.get_items().getItem(i);  
                    if (item.get_value() == calendar.get_key()) {  
                        //The item corresponds to the current "Calendar" - the Value of the item stores the Key of the resource  
                        item.set_imageUrl("Images/checked.gif");  
                    }  
                    else {  
                        item.set_imageUrl("");  
                    }  
                }  
            }  
  
            //Called when the user right-clicks an appointment  
            function appointmentContextMenu(sender, eventArgs) {  
                var menu = $find("<%= SchedulerAppointmentContextMenu.ClientID %>");  
                selectedAppointment = eventArgs.get_appointment();  
                checkResourceMenuItem(menu, selectedAppointment);  
                menu.show(eventArgs.get_domEvent());  
            }  
  
            //Called when the user clicks an item from the appointment context menu  
            function appointmentContextMenuItemClicking(sender, eventArgs) {  
                var clickedItem = eventArgs.get_item();                  
                if (clickedItem.get_text() == "Action") {  
                    //Prevent the menu from closing if the user clicked the "Action" menu item  
                    eventArgs.set_cancel(true);  
                    return;  
                }  
            }  
  
            //Called when the user clicks an item from the appointment context menu  
            function appointmentContextMenuItemClicked(sender, eventArgs)   
            {  
                  
                if (!selectedAppointment)  
                    return;  
  
                var clickedItem = eventArgs.get_item();  
                var scheduler = $find("<%= CalendarRadScheduler.ClientID %>");  
  
                if (clickedItem.get_parent().get_text && clickedItem.get_parent().get_text() == "Action") {  
                    //The user clicked the item corresponding to the "Calendar" resource to which the appointment is assigned  
                    if (clickedItem.get_imageUrl())  
                        return;  
  
                    //Clear all resources   
                    selectedAppointment.get_resources().clear();  
                    //Find the resource corresponding to the clicked item  
                    var calendar = scheduler.get_resources().getResourceByTypeAndKey("Calendar", clickedItem.get_value());  
                    //Add it to the appointment resources collection  
                    selectedAppointment.get_resources().add(calendar);  
                    //Update the appointment  
                    scheduler.updateAppointment(selectedAppointment);  
                }  
            }             
              
            function OnClientRecurrenceActionDialogShowing(sender, eventArgs)  
           {  
               alert('in OnClientRecurrenceActionDialogShowing()');  
               eventArgs.set_cancel(true);    
                
               //Edit this instance only:    
               eventArgs.set_editSeries(false);    
           }          
             
           function CalendarRadScheduler_AppointmentContextMenuItemClicked(sender, eventArgs)  
           {  
            alert('you click a menu button');  
           }  
             
           function OnClientNavigationCommand(sender, eventArgs)  
           {  
              alert('Navigation Command:');  
              alert(eventArgs.get_selectedDate().toString());                
           }  
             
        </script>  
  
    </telerik:RadScriptBlock>  
  
  
<pro:RadAjaxManager ID="RadAjaxManager1" EnableAJAX="true" runat="server" OnAjaxRequest="RadAjaxManager1_AjaxRequest">  
    <AjaxSettings>  
        <pro:AjaxSetting AjaxControlID="CalendarRadScheduler">  
            <UpdatedControls>  
                <telerik:AjaxUpdatedControl ControlID="CalendarRadScheduler" LoadingPanelID="RadAjaxLoadingPanel1" />  
            </UpdatedControls>  
        </pro:AjaxSetting>  
    </AjaxSettings>  
</pro:RadAjaxManager>  
  
        <pro:RadScheduler   
            ID="CalendarRadScheduler"   
            runat="server"   
            EnableAjaxSkinRendering="false"  
            Height="750px"   
            Width="578px"   
            ShowAllDayRow="False"   
            AllowDelete="True"   
            AllowEdit="True"  
            AllowInsert="True"   
            Skin="Office2007"  
            HoursPanelTimeFormat="h:mm tt"   
            MinutesPerRow="15"   
            ShowFullTime="True"  
            StartEditingInAdvancedForm="false"  
            DataKeyField="ID"   
            DataSubjectField="Subject"   
            DataStartField="Start"   
            DataEndField="End"  
            DataRecurrenceField="RecurrenceRule"   
            DataRecurrenceParentKeyField="RecurrenceParentID"  
            DayEndTime="18:30:00"   
            DayStartTime="08:00:00"   
            ShowFooter="false"   
            OnClientAppointmentInserting="OnClientAppointmentInserting"  
            OnClientAppointmentDoubleClick="OnClientAppointmentDoubleClick"  
            OnClientAppointmentEditing="OnClientAppointmentEditing"   
            OnClientAppointmentResizeEnd="OnClientAppointmentResizeEnd"  
            OnAppointmentCreated="CalendarRadScheduler_AppointmentCreated"   
            OnAppointmentDataBound="CalendarRadScheduler_AppointmentDataBound"   
            CustomAttributeNames="NetworkId"   
            OnAppointmentCommand="CalendarRadScheduler_AppointmentCommand"   
            OnFormCreating="CalendarRadScheduler_FormCreating"   
            OnAppointmentContextMenuItemClicked="CalendarRadScheduler_AppointmentContextMenuItemClicked"   
            OnAppointmentUpdate="CalendarRadScheduler_AppointmentUpdate"  
            OnClientRecurrenceActionDialogShowing ="OnClientRecurrenceActionDialogShowing"   
            OnClientNavigationCommand="OnClientNavigationCommand" 
            OnClientAppointmentMoveEnd="OnClientAppointmentMoveEnd"
            OnNavigationCommand="CalendarRadScheduler_NavigationCommand">  
              
            <AppointmentContextMenus>  
                <%--The appointment context menu interaction is handled on the client in this example--%>  
                <%--See the JavaScript code above--%>  
                <telerik:RadSchedulerContextMenu runat="server" ID="SchedulerAppointmentContextMenu">  
                    <Items>  
                        <telerik:RadMenuItem Text="View" Value="CommandView" />  
                        <telerik:RadMenuItem IsSeparator="True" />  
                        <telerik:RadMenuItem Text="Copy" Value="CommandCopy" ImageUrl="/images/copy.gif"/>  
                        <telerik:RadMenuItem IsSeparator="True" />  
                        <telerik:RadMenuItem Text="Edit" Value="CommandEdit" ImageUrl="/images/edit.gif"/>  
                        <telerik:RadMenuItem IsSeparator="True" />  
                        <telerik:RadMenuItem Text="Delete" Value="CommandDelete" ImageUrl="/images/icon_trash.gif" />  
                        <telerik:RadMenuItem IsSeparator="True" />  
                        <telerik:RadMenuItem Text="Action" Visible="false">  
                            <Items>  
                                <telerik:RadMenuItem Text="Development" Value="1" />  
                                <telerik:RadMenuItem Text="Marketing" Value="2" />  
                                <telerik:RadMenuItem Text="Personal" Value="3" />  
                                <telerik:RadMenuItem Text="Work" Value="4" />  
                            </Items>  
                        </telerik:RadMenuItem>  
                         
                    </Items>  
                </telerik:RadSchedulerContextMenu>  
            </AppointmentContextMenus>  
            <AppointmentTemplate>  
                <div>  
                    <%# FormatCalendarMessage() %>  
                </div>  
            </AppointmentTemplate>  
              
        </pro:RadScheduler>  
      
<asp:Label ID="lbl" runat="server" Visible="false"></asp:Label>  
<pro:RadAjaxLoadingPanel   
    ID="RadAjaxLoadingPanel1"   
    runat="server"   
    Transparency="30"  
    BackColor="#E0E0E0"   
    InitialDelayTime="500">  
        <asp:Image ID="Image2" Style="margin-top: 200px" runat="server" ImageUrl="/images/loading.gif" BorderWidth="0px" AlternateText="Loading"></asp:Image>  
</pro:RadAjaxLoadingPanel>  

0
Genady Sergeev
Telerik team
answered on 21 Jan 2010, 10:57 AM
Hello rjb227s,

As we have replied in the other support thread, we need a sample project in order to provide you with a solution for this problem. Could you please open a support ticket and attach a sample there.

All the best,
Genady Sergeev
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
0
rjb227s
Top achievements
Rank 1
answered on 21 Jan 2010, 08:37 PM
Sure thing!

Thanks

Ryan
0
Jon
Top achievements
Rank 1
answered on 17 Sep 2013, 04:29 PM
Ever get this resolved?  I have a similar issue related to Attributes.
In the AppointmentUpdate handler the attribute count is different.


int t1 = e.Appointment.Attributes.Count;
int t4 = e.ModifiedAppointment.Attributes.Count;

I'm fighting another problem where I renamed a CustomAttribute and now I don't see it.
0
Plamen
Telerik team
answered on 20 Sep 2013, 01:50 PM
Hi Jon,

 
This unusual behavior is most probably caused by the way to bind you RadScheduler because we are not aware of such known bug with the custom attributes.

Regards,
Plamen
Telerik
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 the blog feed now.
Asked by
Michael J.
Top achievements
Rank 1
Answers by
Michael J.
Top achievements
Rank 1
Genady Sergeev
Telerik team
rjb227s
Top achievements
Rank 1
Jon
Top achievements
Rank 1
Plamen
Telerik team
Share this question
or