2009-02-11 24 views
1

我有一個包含窗體庫的自定義網站定義。我有一個在InfoPath中創建的表單模板。通過SharePoint功能,我可以部署一切,但我無法弄清楚如何將表單庫的默認窗體更改爲指向我在InfoPath中創建的窗體。我有一個功能,可以很好地部署表單,但我必須手動進入表單庫的高級設置,允許內容類型管理,將默認內容類型更改爲模板,並刪除默認內容類型。SharePoint窗體庫:通過編程或Stsadm命令將內容類型更改爲自定義窗體模板

任何有關如何以編程方式或通過stsadm做到這一點將不勝感激!

科爾比非洲

+0

您是否使用自定義列表定義? – webwires 2009-02-11 21:10:53

回答

1

這是我用來做一些代碼設置列表的內容類型。

void AddContentTypes(SPWeb web) 
    { 
     //get a reference to content types previously installed 
     SPContentType CompanyAContentPage = web.AvailableContentTypes["CompanyA Content Page"]; 
     SPContentType CompanyAWelcomePage = web.AvailableContentTypes["CompanyA Welcome Page"]; 

     //get list to mess with 
     SPList spList = web.Lists["Pages"]; 

     //enable management of content types 
     spList.ContentTypesEnabled = true; 

     //get the content types added to the list (different from the web ones) 
     SPContentType newCompanyAPageContentType = spList.ContentTypes.Add(CompanyAContentPage); 
     SPContentType newCompanyAWelcomePageContentType = spList.ContentTypes.Add(CompanyAWelcomePage); 
     //update list 
     spList.Update(); 

     //get a list of content types for the "new" drop down on the list 
     List<SPContentType> contentTypeList = new List<SPContentType>(); 
     contentTypeList.Add(newCompanyAPageContentType); 
     contentTypeList.Add(newCompanyAWelcomePageContentType); 

     //set the content types for the "new" drop down list 
     spList.RootFolder.UniqueContentTypeOrder = contentTypeList; 
     spList.RootFolder.Update(); 
    } 

與您的問題不完全相同,但我希望它有幫助。

+0

這可能會做一些修改。讓我試試看... – 2009-02-11 22:46:06

相關問題