Solved

Change hyperlinks target to "newtab" only in one page

Posted on 2010-08-12
5
453 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
  • 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

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Suggested Solutions

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…
Calculating holidays and working days is a function that is often needed yet it is not one found within the Framework. This article presents one approach to building a working-day calculator for use in .NET.
This video shows how to use Hyena, from SystemTools Software, to bulk import 100 user accounts from an external text file. View in 1080p for best video quality.

685 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