Home Unanswered Active Tags New Question

Delete with Confirmation

how to delete a event after javascript confirm?

Asked by Anonymous 1 year ago.
Replies
Answer posted by Dan Letecky 1 year ago.

Hi. I put these into the calendar

OnEventDelete="DayPilotCalendar1_EventDelete"
EventDeleteHandling="JavaScript"
EventDeleteJavaScript="eventDelete(e);"

//.--...--.-.. .--...--.-...--...--.-...--...--.-...--...--.-...--...--.-...--...--.-...--...--.-...--...--.-..
With this as the javascript


function eventDelete(e) {

if (confirm('Do you really want to delete this event'))
{
dpc1.eventDeleteCallBack(e);
}

}


//.--...--.-.. .--...--.-...--...--.-...--...--.-...--...--.-...--...--.-...--...--.-...--...--.-...--...--.-..

and this on the code behind

protected void DayPilotCalendar1_EventDelete(object sender, EventDeleteEventArgs e)
{
using (SqlConnection con = new SqlConnection(ConfigurationManager.ConnectionStrings["db"].ConnectionString))
{
con.Open();

SqlCommand cmd = new SqlCommand("DELETE FROM [tblPrint_Schedule] WHERE [id] = @id", con);
cmd.Parameters.AddWithValue("id", e.Value);
cmd.ExecuteNonQuery();
con.Close();//Close the connection
}
int iPrinter = Convert.ToInt32(hdPrinter.Value);
DayPilotCalendar1.DataSource = dbGetEvents(DayPilotCalendar1.StartDate, DayPilotCalendar1.Days, iPrinter);
DayPilotCalendar1.DataBind();
DayPilotCalendar1.Update();
}

//.--...--.-.. .--...--.-...--...--.-...--...--.-...--...--.-...--...--.-...--...--.-...--...--.-...--...--.-..

Hope it helps

LL

Answer posted by LouLou 1 year ago.
New Reply
This reply is
Your name (optional):

DayPilot for ASP.NET WebForms, DayPilot for ASP.NET MVC, DayPilot for Java