views:

37

answers:

0

I am trying to learn how Ajax is working. I want to update a using a Ajax.ActionLink, but I dont manage it to work, please help...

Everything else works in this code(I Delete the comment...).

Here is the code:

   <div id="test">
         <% foreach (var comment in Model.Comments)
            { %>
         <p>
            <b>
               <%: comment.Time %>
               -
               <%: comment.Name %>
            </b>
            <%: Html.ActionLink("Redigera", "CommentEdit", new { id = comment.CommentsID }, new { @class = "ico-edit-comment" })%>
            <%: Ajax.ActionLink("Ta bort", "CommentDelete", "Admin", new { id = comment.CommentsID}, new AjaxOptions { Confirm = "Ta bort kommentar?", UpdateTargetId = "test" })%>
         </p>
         <p>
            <%: comment.Message %>
         </p>
         <% } %>
      </div>

And my controller look like this:

 //
  // Ajax: /Admin/CommentDelete/5
  public ActionResult CommentDelete(int id)
  {
     var commenttodelete = adminCommentRepository.GetComment(id);
     var selectednews = adminNewsRepository.GetArticle(commenttodelete.NewsID);

 adminCommentRepository.Delete(commenttodelete);
 adminCommentRepository.Save();
 return View("ArticleDetails", selectednews);

}

I have a link these three files:

   <script src="/Scripts/MicrosoftAjax.js" type="text/javascript"></script>
   <script src="/Scripts/MicrosoftMvcAjax.js" type="text/javascript"></script>
   <script src="../../Scripts/jquery/js/jquery-1.4.2.min.js" type="text/javascript"></script>