Open new tab on LinkButton Click using C# and VB.Net in ASP.Net

Last Reply 7 months ago By pandeyism

Posted 7 months ago

i want to open new tab using linkbutton for a page ?

 

Posted 7 months ago

Hi akhter,

Refer below sample.

HTML

<asp:LinkButton Text="Open" runat="server" ID="lnk" OnClick="lnk_Click" />

Code

C#

protected void lnk_Click(object sender, EventArgs e)
{
    string Url = "Default.aspx";
    Response.Write("<script language='javascript'>window.open('" + Url + "','_blank','');");
    Response.Write("</script>");
}

VB.Net

Protected Sub lnk_Click(ByVal sender As Object, ByVal e As EventArgs)
    Dim Url As String = "Default.aspx"
    Response.Write("<script language='javascript'>window.open('" & Url & "','_blank','');")
    Response.Write("</script>")
End Sub