Solved

Change hyperlinks target to "newtab" only in one page

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

The Eight Noble Truths of Backup and Recovery

How can IT departments tackle the challenges of a Big Data world? This white paper provides a roadmap to success and helps companies ensure that all their data is safe and secure, no matter if it resides on-premise with physical or virtual machines or in the cloud.

Question has a verified solution.

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

Suggested Solutions

Exception Handling is in the core of any application that is able to dignify its name. In this article, I'll guide you through the process of writing a DRY (Don't Repeat Yourself) Exception Handling mechanism, using Aspect Oriented Programming.
It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
This Micro Tutorial hows how you can integrate  Mac OSX to a Windows Active Directory Domain. Apple has made it easy to allow users to bind their macs to a windows domain with relative ease. The following video show how to bind OSX Mavericks to …
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …

809 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