search envelope-o feed check
Home Unanswered Active Tags New Question
user comment-o

Delete with Confirmation

Asked by Anonymous
12 years ago.

how to delete a event after javascript confirm?

Answer posted by Dan Letecky
12 years ago.
Answer posted by LouLou
12 years 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

This question is more than 3 months old and has been closed. Please create a new question if you have anything to add.