IE div,updatetargetid 在后续请求中不刷新
我在使用 Ajax.ActionLink 的 updatetargetid 属性显示 div 中的部分视图时遇到问题。 这是我的控制器 -
[HandleError]
public class HomeController : Controller
{
static NumberViewModel model = new NumberViewModel();
public ActionResult Index()
{
model.IsDivisibleBy3 = (model.CurrentNumber % 3 == 0);
if (Request.IsAjaxRequest())
{
return PartialView("ViewUserControl1", model);
}
return View();
}
[ActionName("Increment")]
public ActionResult Increment()
{
model.CurrentNumber++;
return RedirectToAction("Index");
}
}
我的索引视图 -
<%@ Page Language="C#" MasterPageFile="~/Views/Shared/Site.Master" Inherits="System.Web.Mvc.ViewPage" %>
<asp:Content ID="Content1" ContentPlaceHolderID="TitleContent" runat="server">
Home Page
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server">
<script type="text/javascript">
function ShowResult() {
var windowWidth = document.documentElement.clientWidth;
var windowHeight = document.documentElement.clientHeight;
leftVal = (windowWidth - 655) / 2;
topVal = (windowHeight - 200) / 2;
$('#result').css({
"left": leftVal,
"top": topVal
});
$('#background').fadeIn("slow");
}
</script>
<div id="background" class="hiddenDiv">
<div id="result" class="popupBox">
</div>
</div>
<%= Ajax.ActionLink("Show", "Index", new AjaxOptions() { UpdateTargetId="result", OnComplete="ShowResult", HttpMethod="Get" })%>
<%= Html.ActionLink("Increment","Increment") %>
</asp:Content>
这适用于 FF 但不适用于 IE6-IE8。
IE场景- 所以当我点击“显示”时,它第一次显示“0 能被 3 整除”。 如果单击“递增”,则数字现在为 1 并且不能被 3 整除。 现在,如果我点击“显示”,它会显示“0 能被 3 整除”。
在 VS 中保留调试点后,我发现第二次请求根本没有发送到服务器。导致没有更新updatetargetid div。
以前有人遇到过这个问题吗?
I am facing an issue while showing the partial view in div with updatetargetid property of Ajax.ActionLink.
This is my controller-
[HandleError]
public class HomeController : Controller
{
static NumberViewModel model = new NumberViewModel();
public ActionResult Index()
{
model.IsDivisibleBy3 = (model.CurrentNumber % 3 == 0);
if (Request.IsAjaxRequest())
{
return PartialView("ViewUserControl1", model);
}
return View();
}
[ActionName("Increment")]
public ActionResult Increment()
{
model.CurrentNumber++;
return RedirectToAction("Index");
}
}
My Index view -
<%@ Page Language="C#" MasterPageFile="~/Views/Shared/Site.Master" Inherits="System.Web.Mvc.ViewPage" %>
<asp:Content ID="Content1" ContentPlaceHolderID="TitleContent" runat="server">
Home Page
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server">
<script type="text/javascript">
function ShowResult() {
var windowWidth = document.documentElement.clientWidth;
var windowHeight = document.documentElement.clientHeight;
leftVal = (windowWidth - 655) / 2;
topVal = (windowHeight - 200) / 2;
$('#result').css({
"left": leftVal,
"top": topVal
});
$('#background').fadeIn("slow");
}
</script>
<div id="background" class="hiddenDiv">
<div id="result" class="popupBox">
</div>
</div>
<%= Ajax.ActionLink("Show", "Index", new AjaxOptions() { UpdateTargetId="result", OnComplete="ShowResult", HttpMethod="Get" })%>
<%= Html.ActionLink("Increment","Increment") %>
</asp:Content>
This works in FF but not in IE6-IE8.
IE Scenario-
So when I Click on 'show', first time it shows '0 is divisible by 3'.
if click 'Increment', the number is now 1 and is not divisible by 3.
Now if I click on 'show' it shows '0 is divisible by 3'.
After keeping debug points in VS, I found- second time the request does not go to the server at all. Resulting in not updating the updatetargetid div.
Does anybody face this issue before?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
即正在缓存重复请求只需将其添加到您的操作方法中:
这样您将拥有:
ie is caching dubplicate request just add this to your action method:
so you will have: