2010-08-04 46 views

回答

1

下面的代碼應該幫助你

  SPList myList=SPContext.Current.Web.Lists["YourList"]; 
      if (myList.BaseType == SPBaseType.DocumentLibrary) 
      { 
       //My List is Document Library 
      } 

      if (myList.BaseType == SPBaseType.GenericList) 
      { 
       //My List is Custom List 
      } 
+0

我嘗試使用客戶端對象來獲取當前網頁model.i我不能夠得到that..please指南我找到它 ClientContext context = new ClientContext(ApplicationContext.Current.Url); ithis在網絡中可用..但它不工作 – TinTin 2010-08-06 07:23:20

2

此代碼將幫助您

 using (SPWeb web = currentSite.OpenWeb()) 
     { 
      foreach (SPList list in web.Lists) 
      { 
       if (list.BaseType == SPBaseType.DocumentLibrary 
        && 
       list.BaseTemplate == SPListTemplateType.DocumentLibrary 
       ) 
       { 
       ListItem li = new ListItem(); 
       li.Text = list.Title; 
       li.Value = list.ID.ToString(); 

       } 
       else if(list.BaseType == SPBaseType.GenericList 
        && 
        list.BaseTemplate == SPListTemplateType.GenericList) 
       { 
        ListItem li = new ListItem(); 
        li.Text = list.Title; 
        li.Value = list.ID.ToString(); 

       } 
      } 
      } 
相關問題