Posted on 2014-07-13
Medium Priority
Last Modified: 2014-07-21
Hi Team,

How to open new window or new tab using response.redirect with out any client side code?
Question by:mannevenu26
LVL 75

Expert Comment

by:käµfm³d 👽
ID: 40193779
The only way to open a new window is either with Javascript or with the target attribute.
LVL 17

Accepted Solution

contactkarthi earned 1500 total points
ID: 40194087
you have to set form target for links in the page to a new blank window. if you want it only for few links and not all links in the page then you need to do a validation before the page submit at server side.

the code below is from stackoverflow.com/a/104881

You need to add the following to your server side link/button:
OnClientClick="aspnetForm.target ='_blank';"
My entire button code looks something like:

<asp:LinkButton ID="myButton" runat="server" Text="Click Me!" 
                OnClientClick="aspnetForm.target ='_blank';"/>

Open in new window

In the server side OnClick I do a Response.Redirect("MyPage.aspx"); and the page is opened in a new window.

The other part you need to add is to fix the form's target otherwise every link will open in a new window. To do so add the following in the header of your POPUP window.
<script type="text/javascript">
    function fixform() {
        if (opener.document.getElementById("aspnetForm").target != "_blank") return;
        opener.document.getElementById("aspnetForm").target = "";
        opener.document.getElementById("aspnetForm").action = opener.location.href;

Open in new window

<body onload="fixform()">

Open in new window

LVL 54

Expert Comment

by:Scott Fell, EE MVE
ID: 40194248
No points.

I just answered the same question on the classic asp side.  This is one of those things where the answer is you can't do that.  In pure html, use target="_blank"    kaufmed has the answer http:#a40193779.

Featured Post

Hire Technology Freelancers with Gigs

Work with freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely, and get projects done right.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Today is the age of broadband.  More and more people are going this route determined to experience the web and it’s multitude of services as quickly and painlessly as possible. Coupled with the move to broadband, people are experiencing the web via …
Problem Hi all,    While many today have fast Internet connection, there are many still who do not, or are connecting through devices with a slower connect, so light web pages and fast load times are still popular.    If your ASP.NET page …
When cloud platforms entered the scene, users and companies jumped on board to take advantage of the many benefits, like the ability to work and connect with company information from various locations. What many didn't foresee was the increased risk…
With just a little bit of  SQL and VBA, many doors open to cool things like synchronize a list box to display data relevant to other information on a form.  If you have never written code or looked at an SQL statement before, no problem! ...  give i…
Suggested Courses
Course of the Month14 days, 8 hours left to enroll

840 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question