2010-10-27 49 views
5

我已創建自定義字段類型(派生自SPFieldText)並添加了自定義屬性「MyProperty」。現在我正在尋找的是,我需要在我的內容類型功能中使用此字段類型。爲內容類型功能中的自定義字段類型設置自定義屬性

如何在我的內容類型定義文件中指定我的自定義屬性,就像我們對OOB字段類型所做的一樣?

我見過一個解決方法here但它只解決了XSD驗證的問題。網站欄正在正確安裝,但是在安裝功能後,沒有爲該欄中的功能指定的值。

預先感謝

阿倫

回答

1

水木清華這樣

<Field ID="{aec8cea1-d0df-49fc-baef-d356e58423f4}" Name="ClientWorkspace" DisplayName="$Resources:Nervogrid.Lauxtermann.Root,FieldWorkspaceDisplayName;" Type="ExtendedWorkspace" Group="$Resources:Nervogrid.Lauxtermann.Root,GroupLauxtermannFields;" AllowDuplicateValues="FALSE"> 
    <Customization> 
     <ArrayOfProperty> 
     <Property> 
      <Name>SiteTemplates</Name> 
      <Value xmlns:q1="http://www.w3.org/2001/XMLSchema" p4:type="q1:string" xmlns:p4="http://www.w3.org/2001/XMLSchema-instance">;#12203;#</Value> 
     </Property> 
     <Property> 
      <Name>HideOnDisplayForm</Name> 
      <Value xmlns:q2="http://www.w3.org/2001/XMLSchema" p4:type="q2:string" xmlns:p4="http://www.w3.org/2001/XMLSchema-instance">$Resources:core,fld_no;</Value> 
     </Property> 
     <Property> 
      <Name>HideOnEditForm</Name> 
      <Value xmlns:q3="http://www.w3.org/2001/XMLSchema" p4:type="q3:string" xmlns:p4="http://www.w3.org/2001/XMLSchema-instance">$Resources:core,fld_yes;</Value> 
     </Property> 
     </ArrayOfProperty> 
    </Customization> 
    </Field> 
1

這爲我工作

 <Field ID="{EB4A62A3-5722-4D12-9AB8-BB36461D8E5D}" Type="MyCustomFieldType" Name="Website" DisplayName="Website" StaticName="Website" Required="true"> 
     <Customization> 
      <ArrayOfProperty> 
      <Property> 
       <Name>MyFirstProperty</Name> 
       <Value>www.stackoverflow.com</Value> 
      </Property> 
      <Property> 
       <Name>MySecondProperty</Name> 
       <Value>stackoverflow</Value> 
      </Property> 
      </ArrayOfProperty> 
     </Customization> 
     </Field> 

您可以訪問屬性的驗證類是這樣的:

string myFieldValue = ((XmlNode[])this.GetCustomProperty("MyFirstProperty"))[0].Value; 
相關問題