将 PartialView 返回到另一个视图的弹出窗口
我有一个 Index.aspx,其中有一个按钮,该按钮将调用控制器,执行一些逻辑并返回 PartialView 控件 - 让我们将其命名为 PopUpPartialView.ascx (作为弹出窗口)。很明显,当用户单击按钮时,弹出窗口(PopUpPartialView)实际上保留在 Index.aspx 的顶部。
在 PopUpPartialView.ascx 中,还有另一个按钮,它返回一个 GenerateList,现在的问题是 - 如何将其传递回 Index.aspx 顶部 PopUpPartialView.ascx 中的相同弹出窗口?我的控制器代码应该是什么样子?
这是我的返回内容:
return PartialView("PopUpPartialView",GenerateList);
这显然不能按我想要的方式工作,因为它没有指向索引页面。我想也许使用 ajax,这样我就可以停留在弹出的 ascx 页面上。很困惑~~请大家指导一下。
谢谢。
I have an Index.aspx with a button inside which that button will call a controller, doing some logic and returning to a PartialView control - let's named it PopUpPartialView.ascx (as a popup). So to make it clear, the popup windows(PopUpPartialView) actually stays ON the top of Index.aspx when user clicks on the button.
In PopUpPartialView.ascx, there is another button, that returns say a GenerateList and now the problem is - how do I pass the thing back to the same popup windows in PopUpPartialView.ascx on the top of Index.aspx as it was before? How should my controller codes look like?
Here's what I have on the return:
return PartialView("PopUpPartialView", GenerateList);
this clearly NOT working as what I want, because it doesn't point back to Index page. I was thinking perhaps to use ajax so that I could stay on that popup ascx page. Confused~~ Someone please guide me.
Thanks.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我的建议是使用一个插件来为您处理所有弹出管道。
我选择的毒药是jqModal。
它非常容易使用 - 本质上是页面上的一个隐藏容器,您可以在初始渲染时或通过 AJAX 在单击事件上加载内容。
因此,在您的示例中,您可以处理按钮事件单击、显示对话框并将部分视图的内容加载到隐藏容器中。
My advice is to use a plugin which handles all the popup plumbing for you.
My poison of choice is jqModal.
It's very easy to work with - essentially a hidden container on the page, and you can load contents in there either on the initial render, or on a click event via AJAX.
So in your example, you could handle the button event click, show the dialog and load the contents of your partial view into the hidden container.