Link List That Controls Another Web Part

Published Tuesday, April 27, 2004 10:49 AM
Occassionally folks will ask to have a list of links in one web part and have another web part display that content.  There is a stupid HTML trick you can do to pull this off.  This is one of those situations where it is nice to have required Internet Explorer.

Add two Content Editor Web Parts to the web part page.

In Web Part A add the following code:   

<iframe name=”myframe” src=”http://www.msn.com”></iframe>

In Web Part B add the following code: 

<li><a href=”http://www.microsoft.com” target=”myframe”>Microsoft</a>
<li><a href=”http://www.msn.com” target=”myframe”>MSN</a>
<li><a href=”http://msdn.microsoft.com” target=”myframe”>MSDN</a>

The net effect is that clicking a link in Web Part B causes it to display inside web part A.

If you want to get fancy, you can use a data view web part to render Web Part A from a list based on the Links list template, and modify the XSL to target the frame in Web Part B.

Filed under:

Comments

# Wilco said on Tuesday, April 27, 2004 4:16 PM

Assuming this is about Sharepoint 2003 (or even ASP.NET 2.0) - why don't you use connections to make this sort of thing possible?

# Westin said on Tuesday, April 27, 2004 10:01 PM

Wilco, you definitely could create a web part that displays a page given a URL from a web part connection. The reason why you wouldn't want to do that is because this is faster and doesn't involve building and deploying said web part.

# Ian Morrish said on Wednesday, April 28, 2004 2:53 AM

Why edit links in html when WSS has a dynamic links list. For an example see
http://www.wssdemo.com/Pages/iFrame.aspx
or a Visio example (requires ActiveX control which will download)

http://www.wssdemo.com/Pages/visio_demo.aspx
Regards,
Ian

# Westin said on Wednesday, April 28, 2004 9:49 AM

Ian,

Is there some built in way to get the list web part to do this or are you modifying the XSL?

# Sunil R. Warrier said on Monday, May 03, 2004 7:40 AM

I there any way to pass URL as a parameter to PageViewer WebPart

# Ian Morrish said on Tuesday, June 08, 2004 4:56 AM

In the Data View Web Part, right click on a URL value and select properties, change the target location. This will apply to every row in the DVWP.
The Page Viewer Web Part doesn't support connections. Cool 3rd party web part that does this
http://dev.collutions.com/Beta/Lists/Announcements/DispForm.aspx?ID=1

# Muhammad Asif Siddiqui said on Friday, June 25, 2004 10:02 AM

I tried your solution but it does not work. New page always opens up in new window:(

# Westin said on Friday, June 25, 2004 12:15 PM

Make sure that the name of the IFRAME is correct in the target property in the source web part's A tag.

# Tiffany said on Thursday, June 07, 2007 1:12 PM

In WSS v2 - To prevent the file from openining in a new window, remove the quotes from around the src file or web address in Web Part A and remove all quotes from web part B. I did this in a web part page and it pulled the docs from the library I was in, so there was no need to include the entire URL, just the name of the document. I suspect that if done on the home page of a subsite, that you would need to include the library name.

Here's the modified code:

Web Part A

<iframe src=Name%20of%20File.vsd name="myframe" width=100% height=100%>

</iframe>

Web Part B

<li><a href=Name%20of%20File.vsd target=myframe>Name of File</a>

<li><a href=Another%20File.vsd%20 target=myframe>Another File</a>

# Dilip said on Thursday, December 20, 2007 11:25 AM

Thanks! Much easier than creating a page viewer web part with a connection.

# Jon B said on Monday, February 18, 2008 9:30 AM

Excellent, this does nearly exactly what I need, however, my 'Web Part A' is an iFrame showing a lengthy html document, with multiple anchors in it, and my 'Web Part B' has links to the various anchors within it... my problem is that when I click on the link to an anchor the whole page scrolls so the Web Part A is at the top browser (it does open the document in the IFrame successfully!) but I do not want the rest of the Web Page to move.. any thoughts please!?

# James Bruiners said on Thursday, November 27, 2008 12:31 PM

Very good & simple demonstration. I just wanted to point out that using a DVWP (yes using SPD) is really easy to pass parameters to Iframes, in-fact it comes out of box with the ability to connect WebParts and edit the XSL all in the GUI.

So for anyone lazy (like me on some days) its a great little tool.

I used this mechanism to display DOCX and PPTX documents next to a DVWP of a Document Library. By using this you get a true preview of each document will you browse you doc library. :)

I also use it on the search results page, hence again, not only a thumbnail but actual Office docs previews (With ribbon with DOCX) ...) not bad.

Remember you have to change the file type DDE message to open in the same browser, but aside from that very easy.

Thanks again.

# Dirk Schäfauer said on Monday, March 22, 2010 9:57 AM

Dear James Bruiner,

I try to create a solution to display .docx in IE and I found your post here.

Could you please tell me how your solution works I'm not be able to get this work...

And could you probably send me a demo of your solution?

That would be nice,

thanks in advance

Dirk

Leave a Comment

(required) 
(required) 
(optional)
(required)