Sharepoint JS CSS 注册

前台注册

适用于2010VisualWebpart,应用程序页

  物理路径:

   1: <SharePoint:ScriptLink Language="javascript" ID="jqueryScriptLink" Name="/_layouts/tgUI/jquery-1.6.4.js" Defer="false" runat="server"/>
   1: <SharePoint:CssRegistration  ID="SDCSSLink"  Name="/_layouts/tgUI/pagestyle.css" runat="server"/>

(2013-3-19)

前台JS注册时不加/_layouts/才能生成缓存安全URL
<SharePoint:ScriptLink Language="javascript" Name="tgUI/jquery-1.6.4.js" Localizable="False"  Defer="false" runat="server"/>
库中: 
1  <SharePoint:ScriptLink Language="javascript" Name="~sitecollection/Style Library/zh-cn/Themable/Core Styles/JS/jquery-1.6.4.js" Defer="false" runat="server"/>
2 
3 <SharePoint:CssRegistration ID="CssRegistration1" Name="/Style Library/Home/CSS/jcarousel.css" runat="server" After="corev4.css" /> 
4 
5 <SharePoint:CssRegistration ID="CssRegistration2" name="<% $SPUrl:~sitecollection/Style Library/~language/Themable/Core Styles/MTPublish.css %>" After="corev4.css" runat="server" EnableCssTheming="false"/>

 

后台注册

适用于2007、2010Webpart,在CreateChildControls中添加

ScriptLink.Register(this.Page, "tgUI/jquery-1.6.4.js", false);
推荐上面这种方式,避免重复注册;且能生成缓存安全 URL,提示找不到该文件
image
 
   1: ScriptLink JqueryJSLink;
   2: JqueryJSLink = new ScriptLink();
   3: JqueryJSLink.ID = "JqueryJSLink";
   4: JqueryJSLink.Language = "javascript";
   5: JqueryJSLink.Name = "/_layouts/tgUI/jquery-1.6.4.js";
   6: this.Controls.Add(JqueryJSLink);

 

(2013-3-7)将CSS注册到Style Library中
CssRegistration.Register(SPUtility.GetServerRelativeUrlFromPrefixedUrl("~sitecollection/Style Library/zh-cn/Themable/Core Styles/**.css”));
 
 
   1: CssRegistration jstreeCSSLink;
   2: jstreeCSSLink = new CssRegistration();
   3: jstreeCSSLink.ID = "jstreeCSSLink";
   4: jstreeCSSLink.Name = "/_layouts/tgUI/jstree/themes/default/style.css";
   5: this.Controls.Add(jstreeCSSLink);

 

 

 

相关主题:SharePoint:ScriptLink测试

posted @ 2012-04-18 20:05  ruijian  阅读(973)  评论(0编辑  收藏  举报