Asp.Net MVC. Updating user control (Shopping Cart) with Ajax
I want to implement a user control which represents a list of the current items in a user's shopping cart, and which is included from within the a master page.
I have it implemented statically, the sessions contents (orders, products) are stored in the database.
I have a ProductsController and a OrderController (shopping cart is basically an order with assigned products and a user id or temporary session id).
With all the different Previews, Betas and the RC, and a lack of a centralized documentation for ASP.NET MVC I find it hard to find proper documentation on this subject.
Could anyone point me to some starting tutorials?
If I understand the question right you want to be able to call a Controller that calls some business logic in the model to update the shopping cart. If this is correct you want to create a JsonResult Controller Action. You will use jQuery to call this action... I wrote a very simple example of this available at http://www.dev102.com/2008/08/19/jquery-and-the-aspnet-mvc-framework/
What I did in the application I am working on at the moment, to make an action in the shopcart controller (name it getAjaxCart or something obvious) that returns a partial view containing the list of items with the price etc, and put that in the div that you have assigned for the shopping cart. Check out the jquery documentation at http://docs.jquery.com/Ajax/jQuery.ajax .