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

How to delete / add Event via postback?

Asked by Martin R.
17 years ago.
Hi!

There are many examples that show how to fill the calendar with events initially. But how should I delete or add an event?
I prepared a ContextMenu for deleting like this:

<DayPilot:DayPilotMenu ID="DayPilotMenu1" runat="server">
<DayPilot:MenuItem NavigateUrl="javascript:alert('Deleting event (id {0})');" Target="" Text="Delete" Title="" />
</DayPilot:DayPilotMenu>

What should I write into the NaviageUrl?
Do I have to rebuild the whole page (e.g. NaviageUrl="MyCalendar.aspx?delete_id={0}) ?

The next question would be, if I have a button which produces a callback, can I then just simply add an event to the DataSource?

Could you maybe provide a complete example for this scenario on the demo page?

Thanks for your Help

Martin
Comment posted by Dan Letecky
17 years ago.
DayPilot 3.1 doesn't support AJAX callbacks so the best way would be to redirect to an URL and then reload the whole page. E.g.

1. Use NavigateUrl="MyCalendar.aspx?delete_id={0}"
2. In MyCalendar.aspx, detect QueryString["delete_id"] and delete the event in the database. Then call Response.Redirect("MyCalendar.aspx", true); to prevent the user to repeat this deleting action (by reloading the page).

However, this is only a temporary solution because DayPilot Pro 3.5 will support AJAX callbacks:

1. NavigateUrl="javascript:DayPilotCalendar1.DeleteEvent({0})"
2. On the server, handle EventDelete event. In DayPilotCalendar1_EventDelete, do the database update, call DayPilotCalendar.DataBind() and DayPilotCalendar.Update(). Then it updates the view on the client side.
3. In DayPilotCalendar1_EventDelete you will also have a chance to apply custom rules for deleting (and possibly deny the deleting action at all).

The syntax may change a little bit in final version of DayPilot Pro 3.5 but the principle will be the same. I will include it in the demos.
Comment posted by Martin R.
17 years ago.
Hi!

Using a page "reload" has the disadvantage that you lose the ViewState.

Using an AJAX-Call has another disadvantage, which is, that you can't access the controls of the page, as an AJAX-Call is a static function.

In my mind a normal PostBack which sends the EventID plus the Action (e.g. ContextEvent("23", "Delete") would be the best.

Any other way is not ASP.Net like in my mind. But I am no expert...
Comment posted by Dan Letecky
17 years ago.
Martin,

As we are discussing your scenario directly by e-mail, I'm not responding here. As soon as we finish the discussion I will post the options here so the others can benefit from it as well.
Comment posted by mamounamine@hotmail.com
17 years ago.

<DayPilot:DayPilotMenu ID="DayPilotMenu1" runat="server"> <DayPilot:MenuItem NavigateUrl="javascript:alert('Deleting event (id {69157})');" Target="" Text="Delete" Title="" />add page</DayPilot:DayPilotMenu>

mamounamine@hotmail.com

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