Solved

Change hyperlinks target to "newtab" only in one page

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

Highfive Gives IT Their Time Back

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
Expando 4 34
C# Application Local DB Connection String 23 61
dynamic menu in asp.net c# 11 29
Check my code out(2) 1 33
This article introduced a TextBox that supports transparent background.   Introduction TextBox is the most widely used control component in GUI design. Most GUI controls do not support transparent background and more or less do not have the…
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…
Sending a Secure fax is easy with eFax Corporate (http://www.enterprise.efax.com). First, Just open a new email message.  In the To field, type your recipient's fax number @efaxsend.com. You can even send a secure international fax — just include t…
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…

758 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

22 Experts available now in Live!

Get 1:1 Help Now