Why Asp.net partial view not returning back?
I am a newbie and just started learning the asp.net mvc, as I was going through the partial view tutorial and I created the small test application which is working fine.
I have a page which has a customers order and each item has an edit buttons for adding or deleting the items and by pressing it I can increase an item or delete an item from the cart. And for such actio开发者_Python百科n I am using
HTML.actionlink("+", "AddToCart", "Orders", new { orderid=tempcart.orderid },
new AjaxOptions()
{
OnBegin = "showplaces",
OnSuccess = "hideloader"
}, null);
so when I click the button it goes to AddToCart() action and update the table in database but it doesn't update the partial view and the loader.gif stays forever on the page and don't call the hideloader() function.
Can you please tell me what's the problem?
1- First user Ajax.ActionLink as you are updating the partial view
2- One thing also place the cart's div id so it can get updated when action finishes.
3- And I had such problem once, so I did the following:
add OnFailure attribute in Ht
Ajax.ActionLink("+", "AddToCart", "Orders", new { orderid=tempcart.orderid },
new AjaxOptions()
{
UpdateTargetId = "cart_divId",
OnBegin = "showplaces",
OnFailure = "ShowDOMExcep",
OnSuccess = "hideloader"
}, null);
and use this method to get DOM exception:
function ShowDOMExcep(context) {
var html = context.get_data();
var placeholder = context.get_updateTarget();
$(placeholder).html(html);
return false;
}
hope this helps ...
精彩评论