我有一个 View 使用 javascript 回调来重新加载局部 View 。无论出于何种原因,即使我可以逐步完成整个过程并看到正在调用和填充的页面,部分类的内容也不会刷新。页面无法显示的任何原因?
代码如下:
<div id="big_image_content">
<% Html.RenderPartial("ZoomImage", Model); %>
</div>
此链接应重新加载上面的 div:
<a href="javascript:void(0)" onclick="$('#big_image_content').load('/ShopDetai/ZoomImage?image_item=something&image_room_scene=something&category=something');"
title="<%= shape.Shape %>" alt="<%= shape.Shape %>">
<img src="http://images.rugs-direct.com/<%= shape.Image.ToLower() %>" width="40" alt="<%= shape.Shape %>">
</a>
部分 View (ZoomImage.ascx) 现在已简化,但仍未加载:
<%@ Control Language="C#" Inherits="System.Web.Mvc.ViewUserControl<RugsDirect.Data.ItemDetailsModel>" %>
<%= Model.Category.ToLower()%>
最后是 Controller 方面:
public ActionResult ZoomImage(string image_item, string image_room_scene, string category)
{
try {
ItemDetailsModel model = GetMainImageContentModel(image_item, image_room_scene, category);
return PartialView("ZoomImage", model);
}
catch (Exception ex)
{
//send the error email
ExceptionPolicy.HandleException(ex, "Exception Policy");
//redirect to the error page
return RedirectToAction("ViewError", "Shop");
}
}
同样,我可以逐步完成整个过程,并且一切似乎都在工作接受页面未重新加载。我什至可以打破部分 View 的 <%= Model.Category.ToLower()%>,但它不会显示。
提前致谢, 比利
最佳答案
我只是在本地设置了您的确切情况,一切对我来说都运行良好。当然,我的模型包含一个随机数生成器,而不是您正在做的任何事情。我也让它在没有随机 url 扩展的情况下工作以击败缓存。
我的问题是,您想要产生的效果到底是什么?哪些信息应该改变,它从什么开始,你希望它改变成什么?您在这里列出了一堆代码并说它们已损坏,但除了“更新”之外,您并没有期望发生什么。
关于javascript - ASP.NET MVC - PartialView 不刷新,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2478409/