none
programmatically set document set Welcome Page View

    Question

  • how to Programmatically set Welcome Page View  on doc lib content Type (Dcoument set)?

    anywone know  how to do that??

     

    Thursday, April 14, 2011 6:37 AM

Answers

  • Hi,

    If you wanted to add web parts or change the welcome page view for one documnet set, you can try the following code.

    e.g.

    static void DocSetDemo(SPList list)
        {
           //get documentset folder to create documentset object
          SPFolder folder = list.Items[new Guid("1711109b-071e-4e82-9d97-d85e4a2b25d0")].Folder;
          Microsoft.Office.DocumentManagement.DocumentSets.DocumentSet docset = Microsoft.Office.DocumentManagement.DocumentSets.DocumentSet.GetDocumentSet(folder);
      
         string url=docset.WelcomePageUrl;
         SPFile defaultPage = list.ParentWeb.GetFile(url);   
         SPLimitedWebPartManager wpm =
         defaultPage.GetLimitedWebPartManager(System.Web.UI.WebControls.WebParts.PersonalizationScope.Shared);
         //add webparts
        // wpm.AddWebPart(.....);
        //change the welcome page 
         docset.ContentTypeTemplate.WelcomePageView = list.Views[0];
         docset.ContentType.Update();
        
        }
    

    Microsoft Online Community Support
    • Marked as answer by KeFang Chen Wednesday, April 20, 2011 10:35 AM
    Friday, April 15, 2011 8:39 AM

All replies

  • Hi there,

    What exactly do you try to change?
    The document set metadata?
    Or the metadata of the items in your document set?


    You can change the page in your document set content type settings (via document set properties).
    You can change the item metadata via the view. It will take the default view you have in the document library.
    Regards, Marijn Somers|| SharePoint Consultant- MCTS SharePoint 2007, 2010 configuring http://www.beyond-it.be || Twitter: http://twitter.com/marijnsomers || http://marijnsomers.blogspot.com
    Thursday, April 14, 2011 8:19 AM
  • Hi,

    If you wanted to add web parts or change the welcome page view for one documnet set, you can try the following code.

    e.g.

    static void DocSetDemo(SPList list)
        {
           //get documentset folder to create documentset object
          SPFolder folder = list.Items[new Guid("1711109b-071e-4e82-9d97-d85e4a2b25d0")].Folder;
          Microsoft.Office.DocumentManagement.DocumentSets.DocumentSet docset = Microsoft.Office.DocumentManagement.DocumentSets.DocumentSet.GetDocumentSet(folder);
      
         string url=docset.WelcomePageUrl;
         SPFile defaultPage = list.ParentWeb.GetFile(url);   
         SPLimitedWebPartManager wpm =
         defaultPage.GetLimitedWebPartManager(System.Web.UI.WebControls.WebParts.PersonalizationScope.Shared);
         //add webparts
        // wpm.AddWebPart(.....);
        //change the welcome page 
         docset.ContentTypeTemplate.WelcomePageView = list.Views[0];
         docset.ContentType.Update();
        
        }
    

    Microsoft Online Community Support
    • Marked as answer by KeFang Chen Wednesday, April 20, 2011 10:35 AM
    Friday, April 15, 2011 8:39 AM