Linkbutton : Open link in a new window (Right Mouse Button)

Asked

Viewed 849 times

0

I wonder if there is any way I can open a new tab by right-clicking, or middle-clicking...

I’m using the "LinkButton" but the command occurs within a OnItemCommand="ListaMenu_ItemCommand". Aspx :

<asp:Repeater ID="ListaMenu" runat="server" 
                                 OnItemCommand="ListaMenu_ItemCommand">
                                 <ItemTemplate>                                      
                                            <li><asp:LinkButton ID="LknMenu" runat="server" Text='<%#Eval("NOMTIPPRO").ToString()%>' ToolTip ='<%#Eval("CODTIPPRO").ToString()%>' target="_blank"> 
                                                </asp:LinkButton>
                                            </li>
                                 </ItemTemplate>
                        </asp:Repeater>

Aspx.Cs :

protected void ListaMenu_ItemCommand(object source, RepeaterCommandEventArgs e)
{
    LinkButton lnkId = (LinkButton)e.Item.FindControl("LknMenu");
    Response.Redirect("~/KnPesquisa.aspx?knMnuTipo=Tipo&knMnuCodTipo=" + lnkId.ToolTip);
}
  • 1

    When you use the middle button, automatically opens a new correct tab? Could explain better what you need?

  • What is happening is that I use Response.Redirect() to open pages, but it would redirect the current answer in the current browser tab, even by clicking the middle or right button. The way is to include the " href " in the " Linkbutton tag ".

  • 1

    You can use the Onclientclick event or Asp control:Hyperlink Onclientclick="window.open('Otherpage.aspx', 'Pagename');"

  • People who code for the middle mouse button are enemies of those who use a laptop touchpad.

3 answers

2


You can use the Onclientclick event or Asp:Hyperlink control

OnClientClick="window.open('OtherPage.aspx', 'PageName');"
  • 1

    I solved otherwise, but thanks for the help, code I used : <asp:LinkButton ID="LknMenu" runat="server" Text='<%#Eval("NOMTIPPRO").ToString()%>' ToolTip ='<%#Eval("CODTIPPRO").ToString()%>' &#xA;href='<%#"KnPesquisa.aspx?knMnuTipo=Tipo&knMnuCodTipo=" + Eval("CODTIPPRO") %>'>

0

Solved !!!

Follows code used.

Aspx:

<asp:Repeater ID="ListaMenu" runat="server" >
                                     <ItemTemplate>                                      
                                                <li><asp:LinkButton ID="LknMenu" runat="server" Text='<%#Eval("NOMTIPPRO").ToString()%>' ToolTip ='<%#Eval("CODTIPPRO").ToString()%>' 
                                                         href='<%#"KnPesquisa.aspx?knMnuTipo=Tipo&knMnuCodTipo=" + Eval("CODTIPPRO") %>'>
                                                    </asp:LinkButton>
                                                </li></ItemTemplate></asp:Repeater>

-2

You can use the code below :

OnClientClick="window.open('OtherPage.aspx', 'PageName');"

Browser other questions tagged

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