tags:

views:

33

answers:

2

Basicaly I want a button that opens a page in a new window containing my http://fake.com/Report/PageFixes... page. Currently I have a button in a form but if there is a better way to do it then I'm up for that too.

<% using (Html.BeginForm("PageFixes", "Report", new { id = 9 }, FormMethod.Get, new { onSubmit="window.open()" })) %>
<% { %>
    <%= Html.CSButton(new ButtonViewData() { Text = "Submit" })%>
<% } %>

Thank you,

Aaron

A: 

How about just some javascript on a button like so

<button type="button" onclick="window.open('http://fake.com/Report/PageFixes/9')"&gt;submit&lt;/button&gt;

Or if you would prefer to build the URL dynamically

<button type="button" onclick="window.open('<%= Request.Url.Scheme + "://"+Request.Url.Authority+Request.ApplicationPath %>Report/PageFixes/9')">submit</button>
Chmod
A: 

You don't need to have a form. Just add the following HTML to your view:

<button type="button" onclick="window.open('<%= Url.Action("PageFixes", "Report", new { id = "9" } ) %>', '_blank'); return false;">submit</button>

I wasn't sure how you were getting the 9 for the ID but I assume it is from your model so you could replace the "9" with Model.ID or something.

The key is generating the url with Url.Action and then just using the basic javascript function window.open to open the url in a new browser window.

Kelsey