新增自定義欄位類

2022-05-10 07:46:04 字數 3315 閱讀 2823

**欄已經為一般使用者和開發者提供了非常好的可重用的能力。更進一步,你可以定義乙個可重用的欄定義,這將為我們帶來更大的靈活性。配合microsoft sharepoint foundation 2010,你可以將建立自定義字段型別的門檻降得很低。

。建立乙個自定義字段控制項的過程為:

1. 建立乙個public 的自定義字段型別的類,並繼承自某個內建的字段型別類,比如spfieldboolen,spfieldchoice,或 spfieldtext。

2. 建立兩個public的構造器,接收特定的引數,並傳遞給相同引數的父類的構造器。

3. 建立乙個xml檔案,作為該欄位型別的部署檔案。你必須將其部署到乙個指定的目錄中,並且需要在場級別啟用該自定義字段型別。

你必須把自定義欄位類定義為public的,並且為其提供兩個非預設的構造器。本例同時還展示了如何通過覆寫getvalidatedstring方法使用正規表示式驗證欄位的值。12

3456

78910

1112

1314

1516

1718

1920

2122

2324

2526

2728

2930

usingsystem;

usingsystem.collections.generic;

usingsystem.linq;

usingsystem.text;

usingmicrosoft.sharepoint;

namespacewingtipcustomfields

publicproductcode(spfieldcollection fields,stringtname,stringdname) :base(fields, tname, dname)

publicoverridestringdefaultvalue

}

publicoverridestringgetvalidatedstring(objectvalue)

if(value.tostring().length != 4)

// 在寫入內容資料庫前總是轉換成大寫的

returnvalue.tostring().toupper();

}

}}12

3456

78910

1112

13<fieldtypes>

<fieldtype>

<fieldname="typename">productcodefield>

<fieldname="parenttype">textfield>

<fieldname="typedisplayname">product codefield>

<fieldname="typeshortdescription">wingtip product codefield>

<fieldname="usercreatable">truefield>

<fieldname="fieldtypeclass">

wingtipcustomfields.productcode,

$sharepoint.project.assemblyfullname$

field>

fieldtype>

fieldtypes>

注意-

microsoft visual studio 2010 中的sharepoint部署工具允許你使用 $sharepoint.project.assemblyfullname$ 佔位符來表示實際的元件名稱。當你編譯原始檔並打包成解決方案包時sharpoint會用實際的元件名稱替換該佔位符。

zblog文章新增自定義字段

註冊外掛程式 default為主題名稱 registerplugin default activeplugin default 掛載外掛程式 default為主題名稱 function activeplugin default add filter plugin函式第乙個引數 filter plug...

ldap新增自定義類(schema)

參考 澳公尺科技的部落格,ldap安裝位置 etc ldap,如果想新增自定義類,則需在schema中新增新schema或者修改主core.schema。如 屬性 attributetype 1.3.6.1.4.1.7914.1.2.1.1 name username desc name of th...

使用自定義字段

轉儲所有自定義字段作為列表顯示乙個特定自定義欄位的值id,mood true mood 將是自定義欄位的id值 顯示相同自定義欄位id的多個值id,songs false 僅在存在時顯示自定義字段 邏輯 url get post meta post id,snippet reference url ...