Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to open a new popup window by clicking an html action link in MVC?

I've a view page in which there's an HTML ActionLink. Now on click of that action link, i want to open a new popup window without closing the previous one. In this new popup window i want to show my existing view page. please provide me a better solution.

like image 442
SRV Avatar asked Mar 19 '12 06:03

SRV


People also ask

How do I open pop ups in MVC?

Step 1 : Start a new ASP.NET MVC Web application. Add a new controller called Home and in the Home controller, the Index method is available to you but there is not a view with it so add a view by right-clicking in Index action. Step 2 : In index. aspx add one HTML button to open our modal popup window like below.

How do you create a link that opens a pop up window?

Open Link in a Popup Window In order to open them in a new window, we add target="_blank" attribute to links. However to open the links in a separate popup window, we can make use of the onclick property and specifying a inline JavaScript code window.

What is action link in MVC?

ActionLink creates a hyperlink on a view page and the user clicks it to navigate to a new URL. It does not link to a view directly, rather it links to a controller's action.


1 Answers

Specify the HTML 'target' attribute using the htmlAttributes parameter. In Razor:

@Html.ActionLink("New Window", "Index", null, new { target= "_blank" })

In ASPX syntax:

<%= Html.ActionLink("New Window", "Index", null, new { target= "_blank" }) %>
like image 85
McGarnagle Avatar answered Sep 21 '22 14:09

McGarnagle