Solved

Change hyperlinks target to "newtab" only in one page

Posted on 2010-08-12
5
456 Views
Last Modified: 2012-05-10
Hi!

I have a page that shouldn't be closed or changed to another one without user confirmation.

So, to avoid closing the window, I'll add some JavaScript code to alert the user.

But I have HyperLinks in masterpage that loads on same page, but in this page, these links must be target to load on another tab (to keep the page open).

I'm thinking to do it by getting all the HyperLinks from masterpage and changing, programatically, the target to "newtab" in page load method.
And I have to do same thing (but targeting to "sametab") with other pages.

There is a better way to do that?

Thanks in advance!
0
Comment
Question by:calypsoworld
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
5 Comments
 
LVL 8

Expert Comment

by:Yiogi
ID: 33427735
I can only think of two ways. One is the one you mention doing it programmatically the second one would be to have a content control in your master page for the links that you can replace in the child pages whenever you need to.

Whatever involves the least effort for you is the one I'd choose.
0
 
LVL 5

Accepted Solution

by:
KiasChaos83 earned 500 total points
ID: 33427890
I think I would handle it the way you want to handle it. Actually, I'm not sure of how I would handle it in detail. I would probably do the following:

1) Create a public property:

public bool bOpenLinkNewTab { get; set; }

2) In the page load set the public property:

protected void Page_Load(...)
{
    bOpenLinkNewTab = true/false;
}

3) in the .aspx markup, use the following

...
<body>
...
<a href="MyOtherPage.aspx" <%=(bOpenLinkNewTab ? "target='_blank'" : "")%>>My Other Page</a>
...
</body>
...
0
 

Author Comment

by:calypsoworld
ID: 33496239
What about if I use another MasterPage with this page?
Maybe it would be easier, right?
0
 

Author Closing Comment

by:calypsoworld
ID: 33667678
Thank you!
0

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

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

We all know that functional code is the leg that any good program stands on when it comes right down to it, however, if your program lacks a good user interface your product may not have the appeal needed to keep your customers happy. This issue can…
Real-time is more about the business, not the technology. In day-to-day life, to make real-time decisions like buying or investing, business needs the latest information(e.g. Gold Rate/Stock Rate). Unlike traditional days, you need not wait for a fe…
NetCrunch network monitor is a highly extensive platform for network monitoring and alert generation. In this video you'll see a live demo of NetCrunch with most notable features explained in a walk-through manner. You'll also get to know the philos…
In this video you will find out how to export Office 365 mailboxes using the built in eDiscovery tool. Bear in mind that although this method might be useful in some cases, using PST files as Office 365 backup is troublesome in a long run (more on t…
Suggested Courses

617 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