2011-06-25 72 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

相關問題