gpt4 book ai didi

jquery - 如何将 ASP.NET MVC 3 View 显示为弹出窗口

转载 作者:行者123 更新时间:2023-12-01 00:04:01 24 4
gpt4 key购买 nike

我需要在 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/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com