Solved

Change hyperlinks target to "newtab" only in one page

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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

A quick way to get a menu to work on our website, is using the Menu control and assign it to a web.sitemap using SiteMapDataSource. Example of web.sitemap file: (CODE) Sample code to add to the page menu: (CODE) Running the application, we wi…
Introduction This article shows how to use the open source plupload control to upload multiple images. The images are resized on the client side before uploading and the upload is done in chunks. Background I had to provide a way for user…
This tutorial gives a high-level tour of the interface of Marketo (a marketing automation tool to help businesses track and engage prospective customers and drive them to purchase). You will see the main areas including Marketing Activities, Design …
Migrating to Microsoft Office 365 is becoming increasingly popular for organizations both large and small. If you have made the leap to Microsoft’s cloud platform, you know that you will need to create a corporate email signature for your Office 365…

867 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

Need Help in Real-Time?

Connect with top rated Experts

16 Experts available now in Live!

Get 1:1 Help Now