New window using asp mvc in html format

I am creating an mvc reporting application. I have a page on which there is a form that contains several drop-down lists to select some criteria for the report. Then I have an enter button to create a report. This button brings up a new view from the same controller. The new view receives values ​​from the page where the criteria are selected from the parameters and uses to fill in its own model of the view. It all works fine.

I would like to open reports in a new window. When I look at the controller, all the parameters that should appear on the selection page are zero. I assume that I will have to pass them through a request that will be selected by the controller. Is there a way I can get dropdownlists from my view page to build a query?

Is this a good way to accomplish what I'm trying to do? Would it be better to use ActionLink instead of the enter button? does it matter?

I hope all this makes sense. Thanks for any thoughts.

+7
asp.net-mvc
source share
2 answers

Just set the target attribute in your form to _blank and it should open a request on a new page / tab depending on the browser you are using.

 <% using (Html.BeginForm(myAction, myController, FormMethod.Post, new { target = "_blank" }) { %> <%-- ... --%> <% } %> 
+29
source share

As NickLarsen says ...

You can use the target="_blank" attribute of the form element to display the results in a new window.

 <form action="/controller/action" method="post" target="_blank"> 

or

 <% Html.BeginForm("action", "controller", FormMethod.Post, new { target="_blank" }); %> //... <% Html.EndForm(); %> 
+4
source share

All Articles