Umbraco-Color Picker–Demo

Demo

Allow the end user has ability to change the background color with pre-defined color.

Steps

1. Create a datatype named BackGroundColor.

image

 

2. Select Color Picker as its render control and select Nvarchar as its Database datatype.

image

 

3. Add the pre-defined colors

image

You can add any number of colors as you wish.

 

4. Add the color to Generic Properties in the TextPage document type.

image

It is reasonable to place Content  BackGround Color in the Generic properties tab as it controls the content’s background color.

 

5. Set the color in the content properties tab

image

After 1 – 4 steps are carried out, the Content BackGround Color comes up to you when you select the properties tab in content page which take TextPage as its template. Select one of color as your background color here.

 

6. Apply the color in the template

image

The code finally looks like the following.

<div class="entry" style="background-color:#<umbraco:Item field="contentBackGroundColor" runat="server" />">
                    <umbraco:item runat="server" field="bodyText"></umbraco:item>
                </div>

 

7. See the effect.

image

 

More knowledge

Umbraco datatypes are created based on the control either shipped with umbraco or self-developed implementing IDataType interface. You can create you specific datatype with specific pre-defined values in different context in your umbraco site. For example, you can create background color 1 and background color 2 based on color picker to control colors in different areas in the template. Have fun here.

 

The source code is available at NovaUmbracoDemo in CodePlex.

Supported by Nova Umbraco

转载于:https://www.cnblogs.com/czy/archive/2012/03/29/2424421.html

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值