How to open a link in a new aspx tab

Asked

Viewed 5,248 times

0

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

follows the code

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

Can someone help me!

  • Friend, I don’t know anything about Asp.net, but following the logic of what you posted, try to do the following: Linkbutton1.Attributes.Add("href", "http://google.com"); Linkbutton1.Attributes.Add("target", "_Blank");

3 answers

3

On page ". aspx", sbstitiua the items you have adding the "_target", this on the page, as follows:

  <asp:LinkButton runat="Server" ....  target="_blank"></asp:LinkButton>

1

Do as Luiz Vichiatto indicated or...

Add the following code:

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

Should stay like this:

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

0

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

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

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

Browser other questions tagged

You are not signed in. Login or sign up in order to post.