2010-10-27 48 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; 
相关问题