Href onclick action open in new window

101 views Asked by At

I'm displaying a pdf icon for the user to click which displays a pdf. I want to get this to open in a new window, is this possible?

I've tried

Onclick OpenWindows _TargetBlank 
<a href="@Url.Action("GetPDF", "Content", new { 
        id = @item.ID 
    })">
    <img src="~/Images/pdf.png" name="LinkToPdf" alt="@item.Image" height="60" width="60" />
</a>

For this to open in a new window

1

There are 1 answers

0
Jasper On

Try using this:

   <a href="@Url.Action("GetPDF", "Content", new { id = @item.ID })" target="_blank"><img src="~/Images/pdf.png" name="LinkToPdf" alt="@item.Image" height="60" width="60" /></a>

i added target="_blank". This tells the link to open in a blank tab.