Asp.net MVC 如何从控制器打开新窗口
所以我有一个场景,我想返回我的 ActionResult...Return View("ViewName", "MasterPageName",model);在特定大小的弹出窗口中,我可以通过...
EG:
public ActionResult PopUp()
{
//do some work...
//I want this returned in a popup window/modal dialog of some sort...
return View("ViewName","MasterPageName",model);
}
从 asp.net mvc 中的控制器完成此操作的合理方法是什么?
提前致谢。
So I have a scenario where I want to return my ActionResult...Return View("ViewName", "MasterPageName",model); in a popup window of a specific size I can pass...
E.G.:
public ActionResult PopUp()
{
//do some work...
//I want this returned in a popup window/modal dialog of some sort...
return View("ViewName","MasterPageName",model);
}
what is a reasonable way to accomplish this from the controller in asp.net mvc?
thanks in advance.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
在服务器端什么也做不了,但你可以装饰你的操作链接,比如
Nothing can be done on server side but you can decorate your action links like
您无法从服务器端的控制器操纵客户端浏览器。您可以做的是在返回的视图中输出脚本,或者调用一个控制器,该控制器通过 AJAX 调用和从客户端弹出窗口返回数据。
You can't manipulate the client side browser from a Controller on the server-side. What you can do is output script in your returned view, or call a controller that returns data via an AJAX call and pop-up from the client-side.
这不是您真正可以从控制器执行的操作,因为这是作为 http 请求的结果在服务器上执行并返回某种形式或其他形式的响应的代码。您需要在客户端上执行此操作,可能使用 javascript,或者您可以调用控制器操作并指定 a 标记的目标属性 为“_blank”。
This is not something you can really do from your controller as this is code that executes on the server as the result of a http request and returns a response of some form or other. You will need to do this on the client, probably using javascript or alternatively you can call your controller action and specify the target attribute of the a tag as '_blank'.
也许您可以尝试使用 jQuery.load() 动态加载渲染的视图
Maybe you can try dynamically loading the rendered view using
jQuery.load()