Take the 2-minute tour ×
SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. It's 100% free, no registration required.

Salvete! I have a Content Editor Web part into which I want to load a simple bit of html (just an input box and a button or two). The file is at /_layouts/myfolder/myfile.html

When I use the "Test Link" option, the file displays fine. But when I "apply" the web part, I get this message in place of the web part: "Cannot retrieve the URL specified in the Content Link property. For more assistance, contact your site administrator."

Now, I am using an admin account - a domain admin account, in fact, so it can't be a permission problem.

I also tried it with a simple text file, but still no solution.

I also tried using an absolute address, such as "http://my.portal.org/_layouts/myfolder/myfile.html", but that didn't do anything either.

How is it that the simple html file can be displayed via "test link", but not as the web part?

I don't want to use a page-viewer, becuase I don't want the html to be in an iframe. I know I can put the html directly into the CEWP, but I want to reuse the html in several places and simply maintain one instance of the code.

share|improve this question

2 Answers 2

up vote 7 down vote accepted

For testing purposes, try putting your html file in a document library in your portal and reference it in the CEWP from there. Eg:

http://my.portal.org/Shared Documents/myfile.html

If this works, then I am guessing it is an authentication issue. Try replicating the issue in Firefox. If it is indeed an authentication issue, you will be prompted for credentials.

UPDATE:

After some digging around I found out that you can neither access content from the layouts folder nor from outside the site collection in the ContentLink property. This is a security feature implemented by Microsoft to avoid cross site scripting.

The only way to allow this is to enable Anonymous Access on the site collection. (in case of _layouts folder)

Or if you are referencing content from another site collection, you will have to enable anonymous access on it:

Enable Anonymous Access in SharePoint 2010

(Tested both options on my SP Environment)

The reason why it is working in the PageViewer Webpart is because:

From MSDN:

If the ContentLink URL points outside of the Windows SharePoint Services Web site to a site that requires authentication, then that site must be isolated. For this situation it is recommended that you use the PageViewerWebPart instead of the ContentEditorWebPart. The PageViewerWebPart renders content within an IFrame. With IFrames, security prompting occurs on the client, enabling the target user to specify a user name and password.

http://msdn.microsoft.com/en-us/library/microsoft.sharepoint.webpartpages.contenteditorwebpart.contentlink.aspx

Another option is to use the Content Link Webpart (available on Codeplex) which is designed as a workaround for this same issue:

Content Link Web Part for SharePoint

share|improve this answer
    
Well, that test worked. So you are right, it must be an authentication issue. Now, how do I remedy that to use the file in my _layouts folder? I am already using firefox, and am logged into sharepoint with my domain admin account and I don't get prompted. –  BGM Aug 4 '12 at 21:56
    
Funny thing is, that the same page's master page comes from that same directory. And there are no issues if I load the page from that directory into a page-viewer web part. That being said, I'm not so sure now, that it is an authentication issue. –  BGM Aug 4 '12 at 22:11
    
Hi, please check my updated answer. –  Vardhaman Deshpande Aug 5 '12 at 9:10
    
Thank you for the very informative, useful answer. You have solved my quandry. The link for the Content-Link Webpart is awesome, even though I am having trouble getting it to work: contentlinkwebpart.codeplex.com/discussions/390448 –  BGM Aug 6 '12 at 15:31
    
I set my collection to anonymous access same with the library and that did not help. I can't get the Content Link WebPart to run. Any other options? –  Batman Dec 17 '13 at 19:00

You cannot link using the content link across sites. I know this first hand. There are, however, workarounds.

I use this in the content editor web part "Content" section and am able to make cross-site references now.

<Content xmlns="http://schemas.microsoft.com/WebPart/v2/ContentEditor">
<![CDATA[​
<script src="jquery.js" type="text/javascript" langauge="javascript"></script
<script type="text/javascript">
    //enter javascript code here        
</script>
ENTER HTML HERE
]]></Content>
share|improve this answer
    
also note that there will be nothing in the content link field –  JuanTrev Jan 10 at 15:45

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.