1

I'm using a asp.net hyperlink control to open a web URL when a user click the hyperlink.

What I want to do is, say user click the hyperlink, so it should open new tab (not a new window).

if the user clicks the link again, it should not open a different tab. It should redirect user to the same tab which opened last time.

Update: here i found

Popup = window.open(URL, "LoginWindow");

This will redirect user to same window when the link is clicked. I'm using this functionality in popup windows. This works perfectly fine with Chrome & Firefox but not in IE.

It always open a new window rather than redirecting to the already opened one. Any Idea to solve this?

Regards

Aruna
  • 1,962
  • 4
  • 25
  • 50

5 Answers5

1

You can also try target="MyWindow" so it always open in this new window/tab. This way we can avoid opening new window/tab for every anchor link we click on.

0

After opening in a new tab (new tab vs new window is a browser option, not an HTML option, see Open link in new tab or window) with

target="_blank" 

you need to set the hyperlink target to self either when generating your the page in c# or in JavaScript

target="_self"

See http://msdn.microsoft.com/en-us/library/system.web.ui.webcontrols.hyperlink.target.aspx

Community
  • 1
  • 1
guymid
  • 1,186
  • 8
  • 11
  • Thanks for the information. But if you have noticed in google blogs, it has button to preview the blog content before publish an article which use the same tab for previewing the content. What i'm trying is similar to that. – Aruna Sep 23 '13 at 12:54
0

The attribute target="_blank" is your only option. Much will depend on users' browser specific settings, you cannot change. In modern browsers this will open a new tab, in others a new window.

Arjen
  • 289
  • 2
  • 4
  • 11
  • Thanks for the information. But if you have noticed in google blogs, it has button to preview the blog content before publish an article which use the same tab for previewing the content. What i'm trying is similar to that... – Aruna Sep 23 '13 at 12:18
0
int i=1;
if(i==1)
{
Hyperlink1.target="_blank";
}
else
{
Hyperlink1.target="_self";
}
user2561316
  • 394
  • 3
  • 7
0

Try this code.Hope this will work for you

 if (ViewState["hasvalue"].ToString() == "Clicked")
            {
            HtmlPage.Window.Navigate(new Uri("form2.aspx"), "_self");
            }
            else // First Time it will be opened in New TAB
            {

      Hyperlink1.target="_blank";
    Hyperlink1.NavigateUrl="form2.aspx";


    }

      // Assign this value to session
    ViewState["hasvalue"] = "Clicked";
    }
user2561316
  • 394
  • 3
  • 7