2011-06-03 47 views
0

我創建一個文件上點擊BUTTOM編程事件設置創建文檔在SharePoint編程設定2010

public void btnCreateDocumentSet_Click(object sender, EventArgs e) 
    { 
     try 
     { 

      lblError.Text = string.Empty; 
      SPSecurity.RunWithElevatedPrivileges(() => 
       { 
        using (web = SPControl.GetContextSite(Context).RootWeb) 
        { 
         web.AllowUnsafeUpdates = true; 
         String url = web.Lists[" Tracker"].RootFolder.ServerRelativeUrl.ToString(); 

         SPList list = web.Lists["Tracker"]; 

         Hashtable props = new Hashtable(); 

         props.Add("Number", "item1"); 
         props.Add("Type", "item2"); 

         DocumentSet ds = DocumentSet.Create(list.RootFolder, "NewDocumentSet3", web.ContentTypes["MydocumentSet2"].Id, props, true); 
         //test 


         //web.Dispose(); 

        } 
       } 
      ); 

     } 

     catch (SPException ex) 
     { 

      lblError.Text = ex.Message; 
     } 

    } 

我沒有得到任何exceptions.On按鈕點擊我正在重定向到類似下面的

錯誤

enter image description here

但是,名爲NewDocumentSet3的文檔集是在文檔庫中創建的,但它看起來像一個文件夾(我的意思是圖標)。當我去文檔庫 - >文檔選項卡 - >新文檔我沒有得到文檔集類型。請在這個問題上建議我。 在此先感謝

+1

關閉Web應用程序的自定義錯誤(在web.config中)以查看實際錯誤。 – Stefan 2011-06-06 09:45:43

回答

1
  1. 首先,關閉自定義錯誤,如屏幕截圖所示。
  2. 然後用所有異常的捕獲來替換你的SPException catch。
  3. 更好的是,在單獨的控制檯應用程序中測試這樣的代碼,而不是在處理程序中。
  4. 在Internet上查找有關如何調試SharePoint應用程序的一些資源。在這種特殊情況下,斷點會讓你走得更遠。
  5. 我對你的名單「[space] Tracker」非常警惕。看起來對我很懷疑。
+0

感謝傢伙問題解決 – 2011-06-27 01:46:31

1

嘗試增加

props.Add("HTML_x0020_File_x0020_Type", "SharePoint.DocumentSet"); 

到GEST到DocumentSet.Create方法傳遞特性的HashSet。

相關問題