[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

Adding " target=_blank" to a String.Format ASP.NET

Posted on 2012-09-04
2
Medium Priority
?
874 Views
Last Modified: 2012-09-04
Hi,

I need to add " target=_blank" to the below code to make the link open in a new page.
Any idea how to add it?

Thank you!!!



 private static readonly string link = "<a href=\"{0}{1}\">{2}</a>";

 if (!match.Value.Contains("://"))
                {
                    body = body.Replace(match.Value, string.Format(link, "http://", match.Value, ShortenUrl(match.Value, 500)));
                }
                else
                {
                    body = body.Replace(match.Value, string.Format(link, string.Empty, match.Value, ShortenUrl(match.Value, 500)));
                }

Open in new window

0
Comment
Question by:Rad1
2 Comments
 
LVL 36

Accepted Solution

by:
Miguel Oz earned 2000 total points
ID: 38365895
change:
private static readonly string link = "<a href=\"{0}{1}\">{2}</a>";
to
private static readonly string link = "<a href=\"{0}{1}\" target="_blank">{2}</a>";

further info check:
http://www.w3schools.com/TAgs/att_a_target.asp
0
 

Author Closing Comment

by:Rad1
ID: 38366109
Excellent!!!!

Thank you!
0

Featured Post

Important Lessons on Recovering from Petya

In their most recent webinar, Skyport Systems explores ways to isolate and protect critical databases to keep the core of your company safe from harm.

Question has a verified solution.

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

Just a quick little trick I learned recently.  Now that I'm using jQuery with abandon in my asp.net applications, I have grown tired of the following syntax:      (CODE) I suppose it just offends my sense of decency to put inline VBScript on a…
Entering time in Microsoft Access can be difficult. An input mask often bothers users more than helping them and won't catch all typing errors. This article shows how to create a textbox for 24-hour time input with full validation politely catching …
This is Part 3 in a 3-part series on Experts Exchange to discuss error handling in VBA code written for Excel. Part 1 of this series discussed basic error handling code using VBA. http://www.experts-exchange.com/videos/1478/Excel-Error-Handlin…
Look below the covers at a subform control , and the form that is inside it. Explore properties and see how easy it is to aggregate, get statistics, and synchronize results for your data. A Microsoft Access subform is used to show relevant calcul…

872 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