【问题标题】:Set Custom Properties for a custom field type within a content type feature为内容类型功能中的自定义字段类型设置自定义属性
【发布时间】:2010-10-27 16:44:46
【问题描述】:

我创建了一个自定义字段类型(派生自 SPFieldText)并添加了一个自定义属性“MyProperty”。现在我正在寻找的是,我需要在我的内容类型功能中使用这个字段类型。

我如何在内容类型定义文件中指定我的自定义属性,就像我们对 OOB 字段类型所做的那样?

我看到了一种解决方法here ,但它只解决了 XSD 验证的问题。网站栏已正确安装,但我在该功能中指定的值未在安装该功能后为该栏设置。

提前致谢

阿伦

【问题讨论】:

    标签: sharepoint


    【解决方案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;
    

    【讨论】:

      【解决方案2】:

      像这样的

      <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>
      

      【讨论】:

        【解决方案3】:

        这是 msdn 论坛上的一个帖子,应该可以回答您的问题。 - http://social.msdn.microsoft.com/forums/en-US/sharepointdevelopment/thread/fb1cb936-3abb-48c2-8d19-49007688dc34/

        【讨论】:

          猜你喜欢
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          • 2011-02-14
          • 2020-04-03
          • 2012-09-03
          • 1970-01-01
          • 2013-02-26
          • 1970-01-01
          相关资源
          最近更新 更多