设为首页 收藏本站
查看: 735|回复: 0

[经验分享] Sharepoint开发之旅(2):SiteDefinition自定义母版页

[复制链接]

尚未签到

发表于 2015-9-28 12:43:14 | 显示全部楼层 |阅读模式
  初次学习sharepoint,本文采用的方法很可能不是最好的,如果您有更好的办法,请在回复中说明,谢谢.
     新建一个SiteDefinition (Farm),并修改webtemp文件中Template的ID(大于10000的任何一个数字,并且不可和已有的SiteDefinition重复)
    在解决方案资源管理器中(Ctrl+W,S)展开SiteDenfinition节点,右键单击SiteDefinition节点,Add->Add New Item 在对话框中右侧选择Visual C# –> Web,右侧选择HTML Page对话框下面的Name更改为 MyMaster.master(这个名称可以自定义).
    更改刚刚加入的MyMaster.master的内容为:      
       <%@ Master Language=&quot;C#&quot; %>
<%@ Register TagPrefix=&quot;SharePoint&quot; Namespace=&quot;Microsoft.SharePoint.WebControls&quot;
Assembly=&quot;Microsoft.SharePoint, Version=14.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c&quot; %>
<%@ Register TagPrefix=&quot;Utilities&quot; Namespace=&quot;Microsoft.SharePoint.Utilities&quot; Assembly=&quot;Microsoft.SharePoint, Version=14.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c&quot; %>
<%@ Import Namespace=&quot;Microsoft.SharePoint&quot; %>
<%@ Assembly Name=&quot;Microsoft.Web.CommandUI, Version=14.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c&quot; %>
<%@ Import Namespace=&quot;Microsoft.SharePoint.ApplicationPages&quot; %>
<%@ Register TagPrefix=&quot;WebPartPages&quot; Namespace=&quot;Microsoft.SharePoint.WebPartPages&quot;
Assembly=&quot;Microsoft.SharePoint, Version=14.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c&quot; %>
<%@ Register TagPrefix=&quot;wssuc&quot; TagName=&quot;Welcome&quot; Src=&quot;~/_controltemplates/Welcome.ascx&quot; %>
<%@ Register TagPrefix=&quot;wssuc&quot; TagName=&quot;MUISelector&quot; Src=&quot;~/_controltemplates/MUISelector.ascx&quot; %>
<!DOCTYPE html PUBLIC &quot;-//W3C//DTD XHTML 1.0 Strict//EN&quot;
&quot;http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd&quot;>
<html id=&quot;Html1&quot; lang=&quot;<%$Resources:wss,language_value%>&quot; xmlns:o=&quot;urn:schemas-microsoft-com:office:office&quot;
runat=&quot;server&quot; dir=&quot;<%$Resources:wss,multipages_direction_dir_value%>&quot;>
<head id=&quot;Head1&quot; runat=&quot;server&quot;>
<meta http-equiv=&quot;X-UA-Compatible&quot; content=&quot;IE=8&quot; />
<meta name=&quot;GENERATOR&quot; content=&quot;Microsoft SharePoint&quot; />
<meta name=&quot;progid&quot; content=&quot;SharePoint.WebPartPage.Document&quot; />
<meta http-equiv=&quot;Content-Type&quot; content=&quot;text/html; charset=utf-8&quot; />
<meta http-equiv=&quot;Expires&quot; content=&quot;0&quot; />
<title>master-><asp:ContentPlaceHolder ID=&quot;PlaceHolderPageTitle&quot; runat=&quot;server&quot;>
</asp:ContentPlaceHolder>
</title>
</head>
<body>
<WebPartPages:WebPartManager ID=&quot;WPManager&quot; runat=&quot;server&quot; />
This is a master page!
<asp:ContentPlaceHolder ID=&quot;PlaceHolderMain&quot; runat=&quot;server&quot;>
</asp:ContentPlaceHolder>
</body>
</html>
这是一个简单的母版页,简单到基本上啥也没有.


更改onet.xml文件.
打开onet.xml文件,你会发现Project –> Modules –> Module[Name=DefaultBlank] 节点下已经包含了我们刚刚添加的master文件MyMaster.master
我们在Project –> Modules 下添加一个 Module[Name=MasterPage]并设置其Url为_catalogs/masterpage
将Module[Name=DefaultBlank]节点下的File[Url=default.aspx]节点移动到Module[Name=MasterPage]节点下.
在Project->Configuration->Modules中添加我们刚刚新建的Module[Name=MasterPage]节点
修改后的onet.xml文件大致为:
<?xml version=&quot;1.0&quot; encoding=&quot;utf-8&quot;?>
<Project Title=&quot;ZhuiSha.SiteDefinition&quot; Revision=&quot;2&quot; ListDir=&quot;&quot; xmlns:ows=&quot;Microsoft SharePoint&quot; xmlns=&quot;http://schemas.microsoft.com/sharepoint/&quot;>
<NavBars>
</NavBars>
<Configurations>
<Configuration ID=&quot;0&quot; Name=&quot;ZhuiSha.SiteDefinition&quot; CustomMasterUrl=&quot;_catalogs/masterpage/MyMaster.master&quot;>
<Lists/>
<SiteFeatures>
</SiteFeatures>
<WebFeatures>
</WebFeatures>
<Modules>
<Module Name=&quot;MasterPage&quot; />
<Module Name=&quot;DefaultBlank&quot; />
</Modules>
</Configuration>
</Configurations>
<Modules>
<Module Name=&quot;MasterPage&quot; Url=&quot;_catalogs/masterpage&quot;>
<File Path=&quot;MyMaster.master&quot; Url=&quot;MyMaster.master&quot; />
</Module>
<Module Name=&quot;DefaultBlank&quot; Url=&quot;&quot; Path=&quot;&quot;>
<File Url=&quot;default.aspx&quot; Path=&quot;default.aspx&quot;>
</File>
</Module>
</Modules>
</Project>



修改SiteDefinition –> default.aspx 为:
<%@ Page language=&quot;C#&quot; MasterPageFile=&quot;~masterurl/custom.master&quot; Inherits=&quot;Microsoft.SharePoint.WebPartPages.WebPartPage,Microsoft.SharePoint,Version=14.0.0.0,Culture=neutral,PublicKeyToken=71e9bce111e9429c&quot;  %>
<%@ Register Tagprefix=&quot;SharePoint&quot; Namespace=&quot;Microsoft.SharePoint.WebControls&quot; Assembly=&quot;Microsoft.SharePoint, Version=14.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c&quot; %>
<%@ Register Tagprefix=&quot;Utilities&quot; Namespace=&quot;Microsoft.SharePoint.Utilities&quot; Assembly=&quot;Microsoft.SharePoint, Version=14.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c&quot; %>
<%@ Register Tagprefix=&quot;asp&quot; Namespace=&quot;System.Web.UI&quot; Assembly=&quot;System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35&quot; %>
<%@ Register Tagprefix=&quot;WebPartPages&quot; Namespace=&quot;Microsoft.SharePoint.WebPartPages&quot; Assembly=&quot;Microsoft.SharePoint, Version=14.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c&quot; %>
<%@ Import Namespace=&quot;Microsoft.SharePoint&quot; %>
<%@ Import Namespace=&quot;Microsoft.SharePoint.ApplicationPages&quot; %>
<%@ Assembly Name=&quot;Microsoft.Web.CommandUI, Version=14.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c&quot; %>

<asp:Content ID=&quot;Content1&quot; ContentPlaceHolderId=&quot;PlaceHolderMain&quot; runat=&quot;server&quot;>
<h1>
Welcome to the custom site
MySiteDefinition
</h1>
<WebPartPages:WebPartZone id=&quot;Zoon1&quot; runat=&quot;server&quot; title=&quot;Zoon1&quot;><ZoneTemplate></ZoneTemplate></WebPartPages:WebPartZone>
</asp:Content>



发布(右键点项目节点,选择Deploy)


新建一个Site Collection 并选择模板为ZhuiSha.SiteDefinition.新建完成后打开新建的网站,即可看到效果.


再次声明,初学SharePoint,希望懂行的多指教.PS:SharePoint难道这么多的东西都需要猜么,太没意思了… DSC0000.png

运维网声明 1、欢迎大家加入本站运维交流群:群②:261659950 群⑤:202807635 群⑦870801961 群⑧679858003
2、本站所有主题由该帖子作者发表,该帖子作者与运维网享有帖子相关版权
3、所有作品的著作权均归原作者享有,请您和我们一样尊重他人的著作权等合法权益。如果您对作品感到满意,请购买正版
4、禁止制作、复制、发布和传播具有反动、淫秽、色情、暴力、凶杀等内容的信息,一经发现立即删除。若您因此触犯法律,一切后果自负,我们对此不承担任何责任
5、所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其内容的准确性、可靠性、正当性、安全性、合法性等负责,亦不承担任何法律责任
6、所有作品仅供您个人学习、研究或欣赏,不得用于商业或者其他用途,否则,一切后果均由您自己承担,我们对此不承担任何法律责任
7、如涉及侵犯版权等问题,请您及时通知我们,我们将立即采取措施予以解决
8、联系人Email:admin@iyunv.com 网址:www.yunweiku.com

所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其承担任何法律责任,如涉及侵犯版权等问题,请您及时通知我们,我们将立即处理,联系人Email:kefu@iyunv.com,QQ:1061981298 本贴地址:https://www.yunweiku.com/thread-120002-1-1.html 上篇帖子: SharePoint 之JS感悟-js脚本 下篇帖子: Sharepoint v3, 如何设置Forms验证模式
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

扫码加入运维网微信交流群X

扫码加入运维网微信交流群

扫描二维码加入运维网微信交流群,最新一手资源尽在官方微信交流群!快快加入我们吧...

扫描微信二维码查看详情

客服E-mail:kefu@iyunv.com 客服QQ:1061981298


QQ群⑦:运维网交流群⑦ QQ群⑧:运维网交流群⑧ k8s群:运维网kubernetes交流群


提醒:禁止发布任何违反国家法律、法规的言论与图片等内容;本站内容均来自个人观点与网络等信息,非本站认同之观点.


本站大部分资源是网友从网上搜集分享而来,其版权均归原作者及其网站所有,我们尊重他人的合法权益,如有内容侵犯您的合法权益,请及时与我们联系进行核实删除!



合作伙伴: 青云cloud

快速回复 返回顶部 返回列表