Creating custom datatypes using the umbraco usercontrol wrap

Source: Internet
Author: User
Tags umbraco

This article describes the technologies used to build websites based on UmbracoCMS.

1. Requirements
The richTexhEditor control is available in the dataType of Umbraco CMS, but it is not perfect. For example, the font size and color are not set. Therefore, you need to replace this control with a more functional control, A third-party control called fckEditor is found on the Internet, which is a text editor.

2. Add steps
1. Create a usercontrol with the following code:
RichTextEditorControl. ascx

<% @ ControlLanguage = "C #" AutoEventWireup = "true" CodeFile = "RichTextEditorControl. ascx. cs"

Inherits = "UserControls_RichTextEditorControl" %>

<% @ RegisterAssembly = "CKEditor. NET" Namespace = "CKEditor. NET" TagPrefix = "CKEditor" %>

<CKEditor: CKEditorControlID = "CKEditor1" BasePath = "~ /Ckeditor "runat =" server "Height =" 450"

Width = "590"> </CKEditor: CKEditorControl>

 

RichTextEditorControl. ascx. cs

Using System;

UsingSystem. Collections. Generic;

Using System. Linq;

Using System. Web;

Using System. Web. UI;

UsingSystem. Web. UI. WebControls;

 

Public partial classUserControls_RichTextEditorControl: System. Web. UI. UserControl, umbraco. editorControls. userControlGrapper. IUsercontrolDataEditor

{

Public string m_UmbracoValue;

Protected void Page_Load (object sender, EventArgs e)

{

If (Page. IsPostBack)

{

M_UmbracoValue = CKEditor1.Text;

}

CKEditor1.Text = m_UmbracoValue;

// Set toolbar options for fckEditor

CKEditor1.config. toolbar = new object []

{

New object [] {"Source", "-", "NewPage", "Preview", "-", "Templates "},

New object [] {"Cut", "Copy", "Paste", "PasteText", "PasteFromWord "},

New object [] {"Undo", "Redo", "-", "Find", "Replace", "-", "SelectAll", "RemoveFormat "},

"/",

New object [] {"NumberedList", "BulletedList", "-", "Outdent", "Indent", "Blockquote "},

New object [] {"JustifyLeft", "JustifyCenter", "JustifyRight", "JustifyBlock "},

New object [] {"Link", "Unlink", "Anchor "},

New object [] {"Image", "Table", "HorizontalRule", "SpecialChar", "PageBreak", "Iframe "},

"/",

New object [] {"Bold", "Italic", "Underline "},

New object [] {"Styles", "Format", "Font", "FontSize "},

New object [] {"TextColor", "BGColor "}

};

}

Public object value

{

Get

{

Returnm_UmbracoValue;

}

Set

{

M_UmbracoValue = value. ToString ();

}

}

}

2. Xslt code:
Log on to the Umbraco background and select the develetypes tab to create a ype.

 

Select umbraco usercontrol wrapper in renderControl and save the settings.

Then we can see the selection box of usercontrol, that is, select the usercontrol we created.

 

So far, we have created a datatype. You can select this DataType in the Document type Tab Of the Settings tab.

 

Related Article

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.