jeudi 25 juin 2015

MVC3 & Ajax : Refresh list to hide a record which was deleted from list by a button click

I have a list which displays Subscribed forums threads and with in each row there is a button to un-subscribe. I works fine using Ajax to unsubscribe, but I want to refresh using Ajax to remove unsubscribed thread from the list. Can anyone please suggest me. My code is as below:

Idea behind using Ajax is because I just want to refresh the list section not entire page.


<% foreach (var thread in Model.threads) { %>
        <td><%: thread.Title %></td>
        <td><%: Ajax.ActionLink("Unsubscribe", "ToggleForumAlertFromList",
                    new { id = thread.ForumId },
                    new AjaxOptions { HttpMethod = "POST", 
                        UpdateTargetId = "none", 
                    new { ID = "togglealertlink" })%>
<% } %>       


public ActionResult ToggleThreadAlertFromList(Guid id)
    // Do stuff to unsubscribe        
    return new EmptyResult();

Aucun commentaire:

Enregistrer un commentaire