ShareOpint service学习笔记之代码创建自定义多行/单行栏----------2

 

添加TestFieldType_cn.cs 文件

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

using Microsoft.SharePoint;
using Microsoft.SharePoint.WebControls;

namespace MyThirdTest0503
{
    //多行文本引用 SPFieldMultiLineText
    //单行编辑文本 SPFieldText 
     public class TestFieldType_cn : SPFieldMultiLineText
    {
        public const string FieldName = "LEE";

        public TestFieldType_cn(SPFieldCollection fields, string fieldName)
            : base(fields, fieldName)
        {
            this.ShowInDisplayForm = true;
        }


        public TestFieldType_cn(SPFieldCollection fields, string fieldName, string displayName)
            : base(fields, fieldName, displayName)
        {
            this.ShowInDisplayForm = true;
        }

        public override BaseFieldControl FieldRenderingControl
        {
            get
            {
                BaseFieldControl fieldControl = new TestFieldType_cnControl();
                fieldControl.FieldName = InternalName;
                
                return fieldControl;
            }
        }

    }

    //多行文本NoteField
    //单行文本TextField
    public class TestFieldType_cnControl : NoteField
    {
        protected override void OnLoad(EventArgs e)
        {
            this.Field.Hidden = true;
            if (!this.Page.IsPostBack)
            {
                try
                {
                    if (this.ControlMode == SPControlMode.New)
                    {
                        //添加是显示
                        this.Field.Hidden = false;
                        this.Field.ReadOnlyField = true;
                    }
                }
                catch (Exception)
                {

                }
            }

        }
    }
}


 

添加XML文件夹->看到解决方法里MyThirdTest0503pm->右键->ADD->sharepoint影射文件夹->在TEMPLATE文件夹里找XML添加上就OK

<?xml version="1.0" encoding="utf-8" ?>
<FieldTypes>
  <FieldType>
    <Field Name="TypeName">NoteBook</Field>
    <Field Name="ParentType">Text</Field>
    <Field Name="TypeDisplayName">NoteBook</Field>
    <Field Name="TypeShortDescription">NoteBook</Field>
    <Field Name="Sortable">TRUE</Field>
    <Field Name="AllowBaseTypeRendering">TRUE</Field>
    <Field Name="Filterable">TRUE</Field>

<!--这里要把你写的.cs文件生成dll 用Reflector7.3工具取出 Name 复制到这里--!>
    <Field Name="FieldTypeClass">
      MyThirdTest0503.TestFieldType_cn,
      MyThirdTest0503PM, Version=1.0.0.0, Culture=neutral, PublicKeyToken=5b0a1c739f085a06
    </Field>
 
    <PropertySchema>
      <Fields>
      </Fields>
    </PropertySchema>
  </FieldType>
</FieldTypes>


 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值