In this article I will explain with an example, how to open Page (View) in New Tab (Window) on Button Click in ASP.Net MVC Razor.
Button cannot be used to open Page (View) in New Tab (Window) and hence using JavaScript’s window.open function, the Page (View) will be opened in New Tab (Window) on Button Click in ASP.Net MVC Razor.
Note: For beginners in ASP.Net MVC, please refer my article ASP.Net MVC Hello World Tutorial with Sample Program example.
 
 
Controller
The Controller consists of two Action methods.
Action method for handling GET operation for Index
Inside this Action method, simply the View is returned.
 
Action method for handling GET operation for About
Inside this Action method, simply the View is returned.
public class HomeController : Controller
{
    // GET: Home
    public ActionResult Index()
    {
        return View();
    }
 
    public ActionResult About()
    {
        return View();
    }
}
 
 
View
The View consists of an HTML Button assigned with an OnClick event handler.
When the Button is clicked, the About View is opened in New Tab (Window) using window.open function of JavaScript.
@{
    Layout = null;
}
 
<!DOCTYPE html>
 
<html>
<head>
    <meta name="viewport" content="width=device-width"/>
    <title>Index</title>
</head>
<body>
    <input type="button" value="Open" onclick="window.open('@Url.Action("About", "Home")')"/>
</body>
</html>
 
 
Screenshot
Open Page (View) in New Tab (Window) on Button Click in ASP.Net MVC
 
 
Browser Compatibility

The above code has been tested in the following browsers.

Internet Explorer  FireFox  Chrome  Safari  Opera 

* All browser logos displayed above are property of their respective owners.

 
 
Downloads