user1011144
user1011144

Reputation: 193

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

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.

Upvotes: 3

Views: 12043

Answers (4)

Gal V
Gal V

Reputation: 32

Maybe you can try dynamically loading the rendered view using jQuery.load()

Upvotes: -1

Emmanuel N
Emmanuel N

Reputation: 7449

Nothing can be done on server side but you can decorate your action links like

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

Upvotes: 2

Andy Rose
Andy Rose

Reputation: 16974

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

Upvotes: 0

rick schott
rick schott

Reputation: 20617

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.

Upvotes: 0

Related Questions