Scheduler for ASP.NET Web Forms - How to display a client-side confirmation message when an appointment is deleted
This example demonstrates how to display a confirmation message before an appointment is deleted.
Users can delete an appointment in the following two ways:
-
Select the Delete context menu item.
To override the context menu behavior, handle the ASPxClientScheduler.MenuItemClicked event as shown below:
function onMenuItemClicked(s, e) { if (e.itemName == "DeleteAppointment") { e.handled = !confirm('Are you sure you want to delete this appointment?'); } }
-
Click the Delete button in an appointment form.
To override the behavior of the Delete button in the appointment form, replace the built-in Delete button with a custom button and handle its Click event.
DialogButton customDeleteButton = dialog.LayoutElements.CreateButton("btnDelete"); customDeleteButton.Text = "Delete"; dialog.InsertAfter(customDeleteButton, dialog.FindLayoutElement("Cancel")); dialog.RemoveLayoutElement("Delete"); ASPxScheduler1.OptionsForms.DialogLayoutSettings.AppointmentDialog.ViewModel.PrepareControl("btnDelete", (ASPxButton button) => { button.ClientSideEvents.Click = "onCustomDeleteButtonClick"; });
function onCustomDeleteButtonClick() { if (confirm('Are you sure you want to delete this appointment?')) { clientScheduler.AppointmentFormDelete(); } }
- Default.aspx (VB: Default.aspx)
- Default.aspx.cs (VB: Default.aspx.vb)