.Net All About

.Net All About

Open New Tab/Window (Response.Redirect open in new web page)

Hello Friends,
Here I am going to explain how to open new tab/window on Button click using asp.net.
A week ago, i have to implement that code. I have option to use javascipt windows.open to open new tab.
But I have to insert or update some database entry. Yeah i know that there is another way to use clientscipt in code behind to achieve this.
But in its simplest form, following code open new tab/window.

<asp:Button ID=”btnNewEntry” runat=”Server” CssClass=”button” Text=”New Entry” OnClick=”btnNewEntry_Click” OnClientClick=”aspnetForm.target =’_blank’;”/>

<%– aspnetForm.target =’_blank’ will add handler to open new tab–%>

protected void btnNewEntry_Click(object sender, EventArgs e)


Response.Write( “<script> window.open( ‘pageName.aspx’ ); </script>”);

// Here we can write javascript code to open new tab

Happy programming.


September 3, 2009 - Posted by | Asp.net, JAVA SCRIPT | , ,


  1. You will be redirected to the script in


    Comment by You will be redirected to the script in seconds | January 16, 2010 | Reply

  2. Great! it is what I need!

    Comment by ginny | March 18, 2010 | Reply

  3. what’s this,
    OnClientClick=”aspnetForm.target =’_blank’
    “aspnetForm” ??

    is it the current form name or the new form?

    Comment by mahee | June 25, 2010 | Reply

    • yeah,its the current form name…
      you will see this using view source from browser!

      Comment by yrbyogi | June 25, 2010 | Reply

  4. if i have my aspx form as “Add Problem.aspx” as and i want a link button in that form to ridirect me to “Previous Issues.aspx” page that needs to open in a new tab. how does it work.?
    Previous Issues

    this doesn’t work

    Comment by mahee | June 25, 2010 | Reply

  5. Previous Issues
    this is the code i used

    Comment by mahee | June 25, 2010 | Reply

    • this code is work perfectly…let me know what is the syntax you are using..?

      Comment by yrbyogi | June 25, 2010 | Reply

      • —Previous Issues —–

        add problem.aspx is the page am having the link label. i want to open previous issues.aspx in a new tab.

        thanx for trying to help. :)

        Comment by mahee | June 25, 2010 | Reply

        • hey the code isnt attaching
          OnClientClick = “Previous Issues.target =’_blank’ ”
          onclick=”lnkPrevious_Click1″>Previous Issues

          Comment by mahee | June 25, 2010 | Reply

          • asp:Button runat=”server” OnClientClick=”aspnetForm.target =’_blank'” OnClick=”lnkPrevious_Click1″

            use above code to open in new tab..
            u just need to specify the aspnetForm.Target instead of Previous Isses.Target!

            Comment by yrbyogi | June 30, 2010 | Reply

            • why u people joking
              Nothing is working.

              Comment by Himanshu | October 25, 2012 | Reply

  6. Thanks Mr!
    This is what I need!

    Comment by Mayur Unagar | June 30, 2010 | Reply

  7. cudn’t figure it out your way, bt i found another method.
    Response.Write(“window.open(‘Assign Specialist.aspx’)”)

    it worked out perfect for me. thanx for ur help :)

    Comment by mahee | July 8, 2010 | Reply

    • oops..script tag inside the double quotes missing

      Comment by mahee | July 8, 2010 | Reply

  8. “i want to open previous issues.aspx in a new tab.”
    You can out more?

    Comment by brocgede | December 16, 2010 | Reply

    • For that follow the code above. u will redirect to previous page.
      If not than find the previous url by using the request.referelurl

      Comment by yrbyogi | December 16, 2010 | Reply

  9. please find the solution for response.redirect in new window from t his post


    Comment by santosh kakani | January 29, 2011 | Reply

  10. Thanx For Such Very Good code.
    but now problem is i just want to open a new tab on only one button click.
    when i click any button on page all events are happening in new tab.
    please help!!!!

    Comment by Sunny | February 24, 2011 | Reply

  11. Great Code at all..
    Good work.

    Comment by gan | April 13, 2011 | Reply

  12. thanks, it works well

    Comment by فرهاد | April 19, 2011 | Reply

  13. sir ,i want to open a new tab on button click event not new window.
    plz help me…

    Comment by adhitya | May 16, 2011 | Reply

    • Just use the code listed in this article.
      Use the Firefox or other browser except the IE. IE will open new window instead of new tab. this is the default behavior in IE.

      Comment by yrbyogi | May 16, 2011 | Reply

  14. Thanks.. I was needed it.

    Comment by Sandeep | May 27, 2011 | Reply

  15. IE default is always new window not tab. no workaround in IE?

    Comment by Will | June 29, 2011 | Reply

  16. but this code
    OnClientClick=”aspnetForm.target =’_blank’;”
    doesn’t work when i deploy my aplication at server & accessed at client machine.
    I have used updatepanel.
    plz reply ASAP?
    Thanks & Regards.

    Comment by Sunny | July 5, 2011 | Reply

  17. Given first solution works only for first click, I have multiple links to open secondForm.aspx in new window. If I load Links.aspx & click on any random link it works perfectly, But not for the second click? no event is fired. Any clue?

    Comment by Shahid Shaikh | February 13, 2012 | Reply

    • Hi Shahid,
      This code will work for every control on page. You just need to define the click events code..

      Comment by yrbyogi | February 13, 2012 | Reply

  18. Thanx it worked

    Comment by Yashaswee | April 6, 2012 | Reply

  19. the code to open page in new tab is working in local but not working on live site.

    Is there any specific reason??

    Comment by shivknit | April 11, 2012 | Reply

  20. thnx a lots…it’s work
    on first try i am unable to make it run because my Button is in update panel, but after that i got the way : i call PostBackTrigger to my button and it’s started working

    Comment by wish | September 24, 2012 | Reply

  21. Please let me know if you’re looking for a article author for your site. You have some really good articles and I feel I would be a good asset. If you ever want to take some of the load off, I’d absolutely love to write some material for your blog in exchange for a link back to mine.
    Please send me an e-mail if interested. Many thanks!

    Comment by website visualize | December 12, 2012 | Reply

  22. Hello, I think your site might be having browser compatibility issues.
    When I look at your website in Chrome, it looks fine but when opening
    in Internet Explorer, it has some overlapping.
    I just wanted to give you a quick heads up! Other then that, amazing blog!

    Comment by managed forex funds | December 18, 2012 | Reply

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s

%d bloggers like this: