Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>The best way to do this would be using AJAX with jQuery</p> <pre><code>function deleteEvent(id) { // The URL to which we will make the AJAX call var url = "MyCalendar.aspx"; // Setup the data to send to the server var sendData = { "action":"deleteEvent", "id":id }; // Make the AJAX call var xhr = $.post(url, sendData, function(result) { // The response is up to the method you implement in the server side, be it json or text. // For simplicity's sake let's assume you return a '0' for OK or '1' for ERROR if(result == '0') { // Remove the event from the calendar since we know it all went well server-side cal.fullCalendar("removeEvents", id); cal.fullCalendar("rerenderEvents"); } else { // There was an error server-side, put a message or something... alert("Could not remove event. Try again later."); } }); xhr.error = function() { // There was an error trying to complete the request alert("Could not complete request."); } } </code></pre> <p>On the server side, I'll assume you are going to use the same page to process the AJAX request, in this case you would do something like this in your PageLoad event:</p> <pre><code>protected void Page_Load(object sender, EventArgs e) { // Check if we received a POST value with name 'action' string action = Request["action"]; if(action != null) { // It's an AJAX Call if(action == "deleteEvent") { // At this point we should expect a POST value with name 'id' int id = int.Parse(Request["id"]); // Execute action DoActionDeleteEvent(id); // Do nothing else since it's an AJAX call return; } } } private void DoActionDeleteEvent(int id) { Response.ContentType = "text/plain"; try { // ToDo: Delete the event from the database // All went well, write 0 in the response. Response.Write("0"); } catch { // There was an error, write 1 in the response Response.Write("1"); } // End the response Response.End(); } </code></pre> <p>That way all changes should reflect in the database and the calendar.</p> <p>As for the edition, you would be doing something very similar, but instead of returning a 0 or 1, you would return a JSON object with the new edited event.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload