This project is read-only.

Ajax.ActionLink not used?

Mar 5, 2011 at 9:02 PM

On page 113 of the MVC Music Store Tutorial V2.0 the tutorial explicitly states that the Remove From Cart link will be implemented using

@Ajax.ActionLink("Remove from cart", "RemoveFromCart",
new { id = item.RecordId }, new AjaxOptions { OnSuccess = "handleUpdate" })

 However in the ensuing discussion on "Ajax Updates using Ajax.ActionLink" that code snippet is never actually used. Why?

The actual code used is

<a href="#" class="RemoveLink" data-id="@item.RecordId">Remove from cart</a>


When I replaced the generated Html ActionLink with this code then IE presented me with an open File Dialog 

See my previous discussion of "RemoveFromCart results in Open file Dialog"

1. Why is the Ajax.ActionLink code not used?

2. What are the differences in usage and behavior of the three different code snippets?

I sure could use some education on this. I appreciate any help you can offer.

Apr 7, 2011 at 12:13 AM
This discussion has been copied to a work item. Click here to go to the work item and continue the discussion.
Apr 18, 2011 at 5:59 PM

In the interest of learning MVC 3, I'd still like to see a response to the OP's questions.  It seems to me that the Ajax.ActionLink approach is the more elegant solution than the '.click' event solution.  Perhaps the ActionLink approach didn't work or maybe the author just wanted to provide an example of a jQuery wire up? 

Furthermore, I see that even in v3.0 the "handleUpdate" function still exists in the completed project.  If I understand the 'fixed' code correctly, it was only the Ajax.ActionLink that would call the handleUpdate function (onSuccess), but since the ActionLink has been redacted, the handleUpdate code is superfluous.  Is my understanding correct?

Thank you.