Redirecting new tab on button click.(Response.Redirect) in asp.net C#

Naresh picture Naresh · Jun 6, 2011 · Viewed 130.7k times · Source

I'm trying to open a page in new tab/window on button click.I tried in the google got this code but its not working.

Can anybody help me with this?

<asp:Button ID="btn" runat="Server" Text="SUBMIT" 
     OnClick="btnNewEntry_Click" OnClientClick="aspnetForm.target ='_blank';"/>

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

When I use this I'm getting error saying

   Microsoft JScript runtime error: 'aspnetForm' is undefined.

Answer

satan singh picture satan singh · Jul 22, 2014

You can do something like this :

<asp:Button ID="Button1" runat="server" Text="Button"
    onclick="Button1_Click" OnClientClick="document.forms[0].target = '_blank';" />