Updatating a span with Ajax.ActionLink

lalkifiepay

New Member
Hi I am trying to create a shopping cart using ajax.I am kind of stuck it's the first time I use ajax.What I am trying to do is create an ajax.Actiolink that will update a Inner text of a span tag.Here is my code so far:\[code\] //This is the span I want to update <span id="UpdateCart">0</span> @Ajax.ActionLink("Add To Cart" , "AddToCart" , "Products", new { ProductId = @products.ElementAt(0).Value }, new AjaxOptions{ Url = "/Product/AddToCart", InsertionMode = InsertionMode.Replace, UpdateTargetId = "UpdateCart", }) public ActionResult AddToCart(string ProductId) { if( User.Identity.IsAuthenticated ) { //CartHelperClass.AddToCart(ProductId); return PartialView(); } else { return RedirectToAction("LogIn" , "Account" , new { returnUrl = "Products" , subCat = Request.QueryString["subcat"] }); } } //This is my PartialView code: <span id="UpdateCart">(5)</span>\[/code\]I would like to be able to take the data inside the partialVieew and update the span at the Top when I click the link.In my case I can not tell if AdToCart action result is even called.What am I doing wrong herE?
 
Back
Top