This project is read-only.

Open a Blogroll link in new window

Topics: Business Logic Layer, Controls
Aug 26, 2009 at 11:12 PM

I would like to keep visitors to my blog on my blog.  As such, I'd prefer to open a new window whenever they click on one of the links I create in my site.  I'm finding that's hard to do (impossible?) with the Blogroll widget.

I had had my wish, BLogroll would work like the Textbox widget.  When you create a hyperlink in a text box, a user interface is presented allowing the user to choose where the link will be opened.  One of the options is "blank".  That works great and I could certainly create a "blogroll looking" widget with the text box but then I loose the formatting associated with BLogroll.

Can someone tell me if it is possible to open a blogroll link in a new window and how to do it?


Aug 27, 2009 at 3:47 AM

In the App_Code\Controls folder, there is a file named Blogroll.cs.

If you open that file up, in the BindControls() section, you'll see 2 links -- webAnchor and feedAnchor.  webAnchor is the link to go to that individual blog entry and feedAnchor is the link to go to the blog's RSS feed.  You can change both of them, by adding the lines shown in bold below:

HtmlAnchor feedAnchor = new HtmlAnchor();
feedAnchor.Target = "_blank";
..... existing code ......

HtmlAnchor webAnchor = new HtmlAnchor();
webAnchor.Target = "_blank";
..... existing code ......

Aug 28, 2009 at 8:18 PM

This worked perfectly.  Thanks Ben!