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