简体   繁体   中英

Asp.net MVC How To Open New Window From Controller

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...

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); 
}

what is a reasonable way to accomplish this from the controller in asp.net mvc?

thanks in advance.

没有什么可以在服务器端完成,但你可以装饰你的行动链接,如

<%= Html.ActionLink("Pop Up", "PopUp", null, new {target="_blank"}) %>

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.

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()动态加载渲染的视图

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM