WSS3SDK之:如何添加一個網站欄

來源:互聯網
上載者:User

我們可以在網站定義中添加一欄,這樣每次使用者建立該類型的網站時網站欄集合中將預設包含該欄。網站定義可以包在Feature中。

當使用者已經建立好了網站,我們可以通過WSS物件模型往網站中添加網站欄。
在網站定義中建立一個網站欄

步驟:
1、在單獨的Feature中建立一個欄位。
2、在我們定義的網站中引用該Feature:
a、在我們的網站Feature中,開啟網站定義XML檔案。
b、在Project元素中,Categories和Category元素下,添加一個引用到內容類型Feature到SiteFeatures或WebFeatures元素中。如下:
XML

<SiteFeatures>
<Feature ID="00BFEA71-1C5E-4A24-B310-BA51C3EB7A57" />
<Feature ID="695B6570-ACDC-4A8E-8545-26EA7FC1D162" />
</SiteFeatures>
<WebFeatures>
<Feature ID="00BFEA71-4EA5-48D4-A4AD-7EA5C011ABE5" />
<Feature ID="00BFEA71-E717-4E80-DEAF-D0C71B360101" />
</WebFeatures>

如果我們對已建立的欄進行修改,WSS並不會將改動寫回到XML欄定義本身。相反,WSS會儲存更改到WSS資料庫條目中。
在已存在的網站中添加欄

我們可以使用WSS物件模型通過編程來添加一欄到已有網站。
步驟:
1、可以通過Fields屬性訪問特定網站的網站欄的集合。該方法返回一個SPFiledCollection對象。
2、使用該對象的下列方法之一來添加欄到網站:

  • Microsoft.SharePoint.SPFieldCollection.Add(Microsoft.SharePoint.SPField)
  • Microsoft.SharePoint.SPFieldCollection.Add(System.String,Microsoft.SharePoint.SPFieldType,System.Boolean)
  • Microsoft.SharePoint.SPFieldCollection.Add(System.String,Microsoft.SharePoint.SPFieldType,System.Boolean,System.Boolean,System.Collections.Specialized.StringCollection)
  • Microsoft.SharePoint.SPFieldCollection.AddFieldAsXml(System.String)
  • Microsoft.SharePoint.SPFieldCollection.AddFieldAsXml(System.String,System.Boolean,Microsoft.SharePoint.SPAddFieldOptions)
  • CreateNewField(System.String,System.String)

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.