作者热门文章
- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我需要在 ASP.NET MVC 3 中将完整 View (.cshtml 网页)显示为弹出窗口。目前,要成为弹出窗口的网页由 MVC Controller 控制,并充当另一个 View 。当从另一个 .cshtml 网页单击按钮时,将显示弹出网页,并且我不想在单击按钮时退出原始 View 。我正在考虑使用 jquery.show() 使 View 成为弹出窗口,尽管这不是必需的。我需要做出哪些改变?
最佳答案
像这样进行 jquery ajax 调用:
$.ajax({
url: /myController/Popup,
type: 'GET',
data: id,
success: function (result) {
$("#myTag").html(result);
}
});
然后在 Controller 中只返回部分 View ,如下所示:
public ActionResult Popup(int id)
{
/* construct the viewmodel */
myViewModel = ....
.
return PartialView("MyPartialView", myViewModel);
}
此部分 View 随后将添加到 myTag。
关于jquery - 如何将 ASP.NET MVC 3 View 显示为弹出窗口,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9745085/
我是一名优秀的程序员,十分优秀!