JavaScriptを持つWebParts管理対象パスでは機能しません
-
10-12-2019 - |
質問
JavaScriptとCSS(モジュール内)のSharePoint 2010 WebPartsを開発しました。開発環境ではなく、製造環境では問題ありません。
Production環境では、管理パスが付いているWebアプリケーション(http://productionapplication/)
があり、「Corp」(http://productionapplication/corp/)
とSiteCollection "(http://productionapplication/corp/product)
。
JavaScriptとCSSにHTTPリクエストを取得すると、WebPartsがロードされます。スクリプトとCSSは"http://productionapplication/corp/product/MyDocumentLibrary/"
の内部に正しくデプロイされています。
どのように私の問題を解決することができますか?
あなたのサポートをありがとう。
解決
Because you're on SharePoint Foundation (thus you cannot use the $SPUrl expression), I would suggest that you resort to some classic ASP.Net tricks to workaround your issue:
Add a runat="server" and id attributes to the link element
<link id="css1" runat="server" rel="stylesheet" type="text/css" media="screen" href="" />
Within the Page_Load method, add this code:
css1.Attributes["href"] = SPUrlUtility.CombineUrl(SPContext.Current.Web.ServerRelativeUrl, "/MyDocumentLibrary/Css/example.css");
他のヒント
Try the SPUrl
token:
<link rel="stylesheet" type="text/css" media="screen" href='<% $SPUrl:~site/MyDocumentLibrary/Css/example.css %>' />
If that doesn't work, try the full relative path to you managed path:
<link rel="stylesheet" type="text/css" media="screen" href="corp/product/MyDocumentLibrary/Css/example.css" />