How to create a custom field type in SharePoint using VS2010 (for example, Ewebeditor)

Source: Internet
Author: User

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)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.