Premise
The project uses Ewebeditor as an online editor to replace the sharepoint2010 automatic multiline editor, with Ewebeditor as the custom field type as an example of how to use VS2010 to create a custom field type in SharePoint.
Development
1. first create an empty sharepoint2010 project with VS2010, such as:
Point to a SharePoint site and deploy it as a farm solution, such as:
2. Add a "map file" to the solution, pointing to template\controltemplates, such as:
Select ControlTemplates to add the user control, such as:
need to delete after adding EGEWebEditorCtl.ascx.cs, such as:
Add the following code to the ascx:
<%@ Control language= "C #"%>
<%@ Assembly name= "Microsoft.SharePoint, version=14.0.0.0, culture=neutral, publickeytoken=71e9bce111e9429c"% >
<%@ Register tagprefix= "SharePoint" assembly= "Microsoft.SharePoint, version=14.0.0.0, Culture=neutral, publickeytoken=71e9bce111e9429c "namespace=" Microsoft.SharePoint.WebControls "%>
<%@ Register assembly= "Ewebeditorcontrol" namespace= "Ewebeditorcontrol" tagprefix= "Ewebeditorcontrol"%>
<sharepoint:renderingtemplate id= "egewebeditorctrl_renderingtemplate" runat= "Server" >
<Template>
<ewebeditorcontrol:ewebeditor id= "EWebEditor1" runat= "Server" basepath= "ewebeditor/" >
</eWebEditorControl:eWebEditor>
</Template>
</SharePoint:RenderingTemplate>
3. add mapped XML folders and files, such as
Add the following XML file
4. inherit SPFieldMultiLineText, such as
Code section:
Namespace TCL. Ep. Extendfield
{
public class Egewebeditorfieldtype:spfieldmultilinetext
{
#region//Construction
Public Egewebeditorfieldtype (Spfieldcollection, String fieldName)
: Base (Fields, FieldName)
{
}
Public Egewebeditorfieldtype (spfieldcollection fields, String typeName, String displayName)
: Base (Fields, TypeName, DisplayName)
{
}
#endregion
#region//Construction controls
<summary>
Constructing controls
</summary>
public override Basefieldcontrol Fieldrenderingcontrol
{
[SharePointPermission (SecurityAction.LinkDemand, ObjectModel = True)]
Get
{
Basefieldcontrol FieldControl = new Egewebeditorfieldtypecontrol ();
Fieldcontrol.fieldname = this. InternalName;
return FieldControl;
}
}
#endregion
}
}
5. inherit Basefieldcontrol, such as:
Code section:
Namespace TCL. Ep. Extendfield
{
public class Egewebeditorfieldtype:spfieldmultilinetext
{
#region//Construction
Public Egewebeditorfieldtype (Spfieldcollection, String fieldName)
: Base (Fields, FieldName)
{
}
Public Egewebeditorfieldtype (spfieldcollection fields, String typeName, String displayName)
: Base (Fields, TypeName, DisplayName)
{
}
#endregion
#region//Construction controls
<summary>
Constructing controls
</summary>
public override Basefieldcontrol Fieldrenderingcontrol
{
[SharePointPermission (SecurityAction.LinkDemand, ObjectModel = True)]
Get
{
Basefieldcontrol FieldControl = new Egewebeditorfieldtypecontrol ();
Fieldcontrol.fieldname = this. InternalName;
return FieldControl;
}
}
#endregion
}
}
Precautions:
1. Ewebeditor DLL must be copied to the bin under the corresponding site. The prompt cannot find the corresponding dependency, otherwise it will not work. The following error:
2. other relevant JS and CSS must also be copied to the corresponding site, if posted to _layouts or templates under the prompt cannot be found: 404 Not Found.
3. must purchase genuine, genuine support Word,excel,wps document import, image upload automatically, the format is basically unchanged. such as:
4. Custom Type
How to create a custom field type in SharePoint using VS2010 (for example, Ewebeditor)