2011-06-25 70 views
0

iam新的SharePoint 2010开发人员和iam创建网站定义,但我无法更改使用onet.xml文件的默认欢迎页面,我尝试了所有可能的方式,但我失败了,请任何人都可以帮忙?我如何更改网站定义默认欢迎页面

如果有人可以,我想要一个名为Home的自定义欢迎页面作为例子的网站定义。

+0

你应该在sharepoint.stackexchange.com上试试这个问题 – Jeff

回答

1

与下列接收器

public override void FeatureActivated(SPFeatureReceiverProperties properties) 
    { 
     try 
     { 
      var currentWeb = (SPWeb) properties.Feature.Parent; 
      var pubWeb = PublishingWeb.GetPublishingWeb(currentWeb); 

      SPFile homePageFile = currentWeb.GetFile("Pages/custompage.aspx"); 
      pubWeb.DefaultPage = homePageFile; 

      pubWeb.Update(); 
     } 
     catch (Exception e) 
     { 
       //log etc.. 
     } 
    } 

不要忘记refrence Microsoft.SharePoint.Publishing DLL创建Web范围的功能。

使用功能装订。功能装订参考http://msdn.microsoft.com/en-us/library/ff382738(v=office.12).aspx

将以下代码添加到您的ONET.xml中 不要预见激活发布功能。

<Configurations> 
     <Configuration ID="0" ...> 

     <WebFeatures> 
         <!-- Publishing Feature ID --> 
         <Feature ID="GUID" /> 
         <!-- Your Feature ID --> 
      <Feature ID="GUID" /> 
     </WebFeatures> 

</Configuration> 
+0

是的,谢谢你everthing还行 – qablan89

相关问题