How to open a link in a new aspx tab

0

I'm trying to open a new page on a different tab, through aspx, I got a code on the internet that does this, however, it only works with clicks.

follow the code

LinkButton1.Attributes.Add("onclick", "window.open('../conheca-os-alimentos-aprovacao.aspx');return false;");

Someone can help me!

    
asked by anonymous 17.07.2015 / 17:44

3 answers

3

In the ".aspx" page, you can specify the items you have by adding "_target" on the page as follows:

  <asp:LinkButton runat="Server" ....  target="_blank"></asp:LinkButton>
    
17.07.2015 / 18:14
1

Do as Luiz Vichiatto indicated or ...

Add the following code:

LinkButton1.Attributes.Add("target", "_blank");

It should look like this:

LinkButton1.Attributes.Add("target", "_blank");
LinkButton1.Attributes.Add("onclick", "window.open('../conheca-os-alimentos-aprovacao.aspx');return false;");
    
19.07.2015 / 01:41
0

Hello! Try using the code below directly on the LinkButton. When you specified that only works with clicks, what would you like to do then? Do you want some internal business rule on the page to open a new tab? Could you specify the question better?

Obs: Open new tab or new window without user action (without the click) is considered pop-up and blocked by the browser in most cases.

  <asp:LinkButton runat="server" Text="teste" ID="lnkTeste" OnClientClick="window.open('http://www.google.com');" target="_blank"></asp:LinkButton>
    
20.08.2015 / 15:30