[SOLVED] how to open a page in new tab on button click in asp.net?

Issue

I want to open a page in new tab of browser on button click.

I have searched a lot on google but i couldn’t find anything.

Here is my button.

   <asp:Button ID="btnNewEntry" runat="Server" CssClass="button" Text="New Entry" OnClick="btnNewEntry_Click" />

    protected void btnNewEntry_Click(object sender, EventArgs e)
    {      
        Response.Redirect("New.aspx");
    }

Can you please help me how i can do this ?

Solution

You could use window.open. Like this:

protected void btnNewEntry_Click(object sender, EventArgs e)
{ 
   Page.ClientScript.RegisterStartupScript(
   this.GetType(),"OpenWindow","window.open('YourURL','_newtab');",true);
}

Answered By – Arion

Answer Checked By – Jay B. (BugsFixing Admin)

Leave a Reply

Your email address will not be published. Required fields are marked *