<?xml version="1.0" encoding="utf-8"?><feed xmlns="http://www.w3.org/2005/Atom"><title type="text">博客园_洋心</title><subtitle type="text">乾</subtitle><id>http://feed.cnblogs.com/blog/u/26933/rss</id><updated>2012-05-29T08:20:27Z</updated><author><name>曹宗颖</name><uri>http://www.cnblogs.com/czy/</uri></author><generator>feed.cnblogs.com</generator><link rel="alternate" type="text/html" href="http://www.cnblogs.com/czy/"/><link rel="self" type="application/atom+xml" href="http://feed.cnblogs.com/blog/u/26933/rss"/><entry><id>http://www.cnblogs.com/czy/archive/2012/05/29/2524125.html</id><title type="text">Coding with JMP3</title><summary type="text">JMP3 is the best candidate to play mp3 audio files on the page. Here we go the files for JMP3. JMP3 plugin (jquery.jmp3.js)JQuery (jquery-1.7.2.min.js)Flash player (singlemp3player.swf) Configuration Copy jquery.jmp3.js, juqery.*.js, singlemp3player.swf to scripts folder or some other folder you lik</summary><published>2012-05-29T08:15:00Z</published><updated>2012-05-29T08:15:00Z</updated><author><name>曹宗颖</name><uri>http://www.cnblogs.com/czy/</uri></author><link rel="alternate" href="http://www.cnblogs.com/czy/archive/2012/05/29/2524125.html"/><link rel="alternate" type="text/html" href="http://www.cnblogs.com/czy/archive/2012/05/29/2524125.html"/><content type="html">&lt;p&gt;JMP3 is the best candidate to play mp3 audio files on the page. Here we go the files for JMP3.&lt;/p&gt; &lt;ol&gt;&lt;li&gt;&lt;a href="http://www.sean-o.com/jquery/jmp3/jquery.jmp3.js" target="_blank"&gt;JMP3 plugin&lt;/a&gt; (jquery.jmp3.js)&lt;/li&gt;&lt;li&gt;&lt;a href="http://docs.jquery.com/Downloading_jQuery" target="_blank"&gt;JQuery&lt;/a&gt; (jquery-1.7.2.min.js)&lt;/li&gt;&lt;li&gt;&lt;a href="http://www.sean-o.com/files/singlemp3player.zip" target="_blank"&gt;Flash player&lt;/a&gt; (singlemp3player.swf)&lt;/li&gt;&lt;/ol&gt; &lt;p&gt;&lt;strong&gt;Configuration&lt;/strong&gt;&lt;/p&gt; &lt;ol&gt;&lt;li&gt;Copy jquery.jmp3.js, juqery.*.js, singlemp3player.swf to scripts folder or some other folder you like.&lt;/li&gt;&lt;li&gt;Set the initial values for JMP3 in jquery.jmp3.js &lt;/li&gt;&lt;/ol&gt; &lt;p&gt;Let&amp;#8217;s take scripts folder as example. After the aforementioned files are copied to scripts folder, you would like to open the jquery.mp3.js to set the initial values.&lt;/p&gt;jQuery.fn.jmp3 = &lt;span style="color: blue;"&gt;function&lt;/span&gt;(passedOptions){&lt;br/&gt;    &lt;span style="color: rgb(0, 100, 0);"&gt;// hard-wired options&lt;br/&gt;    &lt;/span&gt;&lt;span style="color: blue;"&gt;var &lt;/span&gt;playerpath = &lt;span style="color: maroon;"&gt;"/Scripts/"&lt;/span&gt;;                    &lt;span style="color: rgb(0, 100, 0);"&gt;// SET THIS FIRST: path to singlemp3player.swf&lt;br/&gt;&lt;br/&gt;    // passable options&lt;br/&gt;    &lt;/span&gt;&lt;span style="color: blue;"&gt;var &lt;/span&gt;options = {&lt;br/&gt;        &lt;span style="color: maroon;"&gt;"filepath"&lt;/span&gt;: &lt;span style="color: maroon;"&gt;"/Media/"&lt;/span&gt;,                                        &lt;span style="color: rgb(0, 100, 0);"&gt;// path to MP3 file (default: current directory)&lt;br/&gt;        &lt;/span&gt;&lt;span style="color: maroon;"&gt;"backcolor"&lt;/span&gt;: &lt;span style="color: maroon;"&gt;""&lt;/span&gt;,                                    &lt;span style="color: rgb(0, 100, 0);"&gt;// background color&lt;br/&gt;        &lt;/span&gt;&lt;span style="color: maroon;"&gt;"forecolor"&lt;/span&gt;: &lt;span style="color: maroon;"&gt;"ffffff"&lt;/span&gt;,                                &lt;span style="color: rgb(0, 100, 0);"&gt;// foreground color (buttons)&lt;br/&gt;        &lt;/span&gt;&lt;span style="color: maroon;"&gt;"width"&lt;/span&gt;: &lt;span style="color: maroon;"&gt;"25"&lt;/span&gt;,                                        &lt;span style="color: rgb(0, 100, 0);"&gt;// width of player&lt;br/&gt;        &lt;/span&gt;&lt;span style="color: maroon;"&gt;"repeat"&lt;/span&gt;: &lt;span style="color: maroon;"&gt;"no"&lt;/span&gt;,                                        &lt;span style="color: rgb(0, 100, 0);"&gt;// repeat mp3?&lt;br/&gt;        &lt;/span&gt;&lt;span style="color: maroon;"&gt;"volume"&lt;/span&gt;: &lt;span style="color: maroon;"&gt;"50"&lt;/span&gt;,                                        &lt;span style="color: rgb(0, 100, 0);"&gt;// mp3 volume (0-100)&lt;br/&gt;        &lt;/span&gt;&lt;span style="color: maroon;"&gt;"autoplay"&lt;/span&gt;: &lt;span style="color: maroon;"&gt;"false"&lt;/span&gt;,                                &lt;span style="color: rgb(0, 100, 0);"&gt;// play immediately on page load?&lt;br/&gt;        &lt;/span&gt;&lt;span style="color: maroon;"&gt;"showdownload"&lt;/span&gt;: &lt;span style="color: maroon;"&gt;"true"&lt;/span&gt;,                                &lt;span style="color: rgb(0, 100, 0);"&gt;// show download button in player&lt;br/&gt;        &lt;/span&gt;&lt;span style="color: maroon;"&gt;"showfilename"&lt;/span&gt;: &lt;span style="color: maroon;"&gt;"true"                                &lt;/span&gt;&lt;span style="color: rgb(0, 100, 0);"&gt;// show .mp3 filename after player&lt;br/&gt;    &lt;/span&gt;};&lt;br/&gt;&lt;p&gt;The comments shipped with jquery.mp3.js states very clearly for the variable and fields. Since the singlemp3play.swf is located in the scripts folder, the palyerpath is set with &amp;#8220;/Scripts/&amp;#8221;. &lt;/p&gt;&lt;p&gt;&amp;nbsp;&lt;/p&gt;&lt;p&gt;Another value worthy of pointing out is filepath in options object. The filepath in the options object combining with filename in jmp3 in the front page becomes the complete url path for the mp3 file. So you can leave filepath in the options object empty only if you specify the complete url path for the mp3 file in the front page. In the aforementioned code, I set filepath with &amp;#8220;/Media/&amp;#8221; since I place the mp3 files in the Media folder.&lt;/p&gt;&lt;p&gt;&amp;nbsp;&lt;/p&gt;&lt;p&gt;&lt;strong&gt;Use JMP3 in the Front Page&lt;/strong&gt;&lt;/p&gt;&lt;p&gt;In the front page, please add the following code in the *.ascx or *.aspx.&lt;/p&gt;&lt;span style="color: blue;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: maroon;"&gt;script &lt;/span&gt;&lt;span style="color: red;"&gt;type&lt;/span&gt;&lt;span style="color: blue;"&gt;="text/javascript" &lt;/span&gt;&lt;span style="color: red;"&gt;src&lt;/span&gt;&lt;span style="color: blue;"&gt;="../Scripts/jquery-1.7.2.min.js"&amp;gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: maroon;"&gt;script&lt;/span&gt;&lt;span style="color: blue;"&gt;&amp;gt;&lt;br/&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: maroon;"&gt;script &lt;/span&gt;&lt;span style="color: red;"&gt;type&lt;/span&gt;&lt;span style="color: blue;"&gt;="text/javascript" &lt;/span&gt;&lt;span style="color: red;"&gt;src&lt;/span&gt;&lt;span style="color: blue;"&gt;="../Scripts/jquery.jmp3.js"&amp;gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: maroon;"&gt;script&lt;/span&gt;&lt;span style="color: blue;"&gt;&amp;gt;&lt;br/&gt;&lt;/span&gt;&lt;span style="color: blue;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: maroon;"&gt;script &lt;/span&gt;&lt;span style="color: red;"&gt;type&lt;/span&gt;&lt;span style="color: blue;"&gt;="text/javascript"&amp;gt;&lt;br/&gt;    &lt;/span&gt;$(document).ready(&lt;span style="color: blue;"&gt;function &lt;/span&gt;() {&lt;br/&gt;        &lt;span style="color: rgb(0, 100, 0);"&gt;//jMP3 init&lt;br/&gt;        &lt;/span&gt;$(&lt;span style="color: maroon;"&gt;".mp3player"&lt;/span&gt;).jmp3({&lt;br/&gt;            showfilename: &lt;span style="color: maroon;"&gt;"false"&lt;/span&gt;,&lt;br/&gt;            backcolor: &lt;span style="color: maroon;"&gt;"000000"&lt;/span&gt;,&lt;br/&gt;            forecolor: &lt;span style="color: maroon;"&gt;"00ff00"&lt;/span&gt;,&lt;br/&gt;            width: 30,&lt;br/&gt;            showdownload: &lt;span style="color: maroon;"&gt;"true"&lt;br/&gt;        &lt;/span&gt;});&lt;br/&gt;    });&lt;br/&gt;&lt;span style="color: blue;"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: maroon;"&gt;script&lt;/span&gt;&lt;span style="color: blue;"&gt;&amp;gt;&lt;br/&gt;&lt;/span&gt;&lt;span style="color: blue;"&gt;&amp;lt;!&amp;#8212;code snippet in a repeater&amp;#8212;&amp;gt;&lt;/span&gt;&lt;span style="color: blue;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: maroon;"&gt;span &lt;/span&gt;&lt;span style="color: red;"&gt;id&lt;/span&gt;&lt;span style="color: blue;"&gt;="mp3player" &lt;/span&gt;&lt;span style="color: red;"&gt;class&lt;/span&gt;&lt;span style="color: blue;"&gt;="mp3player"&amp;gt;&lt;br/&gt;                    &lt;/span&gt;&lt;span style="background: yellow;"&gt;&amp;lt;%&lt;/span&gt;&lt;span style="color: blue;"&gt;#&lt;/span&gt;Eval(&lt;span style="color: rgb(163, 21, 21);"&gt;"RelativeMp3Url"&lt;/span&gt;)&lt;span style="background: yellow;"&gt;%&amp;gt;&lt;/span&gt;&lt;span style="color: blue;"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: maroon;"&gt;span&lt;/span&gt;&lt;span style="color: blue;"&gt;&amp;gt;&lt;br/&gt;&lt;/span&gt;&lt;p&gt;In the aforementioned code, the mp3 url (filename) is put in a &amp;lt;span&amp;gt;. The mp3 audio player will display in the spans that have &amp;#8220;mp3player&amp;#8221; class. &lt;/p&gt;&lt;p&gt;&lt;strong&gt;Is It A Bug?&lt;/strong&gt;&lt;/p&gt;&lt;p&gt;I found a strange issue in the repeater that contains multiple mp3 playing url. If the first occurrence of the mp3 url is not valid, the successive mp3 urls will not be represented with jmp3 player even if they have correct mp3 urls. I will appreciate if some jquery experts give the answer here.&lt;/p&gt;&lt;p&gt;&amp;nbsp;&lt;/p&gt;&lt;p&gt;supported by &lt;a href="http://www.novasoftware.com/Developer/Umbraco.aspx?utm_source=codeplex&amp;amp;utm_medium=post&amp;amp;utm_campaign=czy" target="_blank"&gt;Nova Umbraco&lt;/a&gt;&lt;/p&gt; &lt;img src="http://www.cnblogs.com/czy/aggbug/2524125.html?type=1" width="1" height="1" alt=""/&gt;&lt;p&gt;&lt;a href="http://www.cnblogs.com/czy/archive/2012/05/29/2524125.html" target="_blank"&gt;本文链接&lt;/a&gt;&lt;/p&gt;</content></entry><entry><id>http://www.cnblogs.com/czy/archive/2012/04/22/2465306.html</id><title type="text">Practices on Umbraco DataType Development</title><summary type="text">Umbraco is the most powerful and flexible CMS I have ever seen so far. I just write this essay to demonstrate how to develop an Umbraco DataType for the folks who have basic Asp.net development knowle...</summary><published>2012-04-22T10:30:00Z</published><updated>2012-04-22T10:30:00Z</updated><author><name>曹宗颖</name><uri>http://www.cnblogs.com/czy/</uri></author><link rel="alternate" href="http://www.cnblogs.com/czy/archive/2012/04/22/2465306.html"/><link rel="alternate" type="text/html" href="http://www.cnblogs.com/czy/archive/2012/04/22/2465306.html"/><content type="html">&lt;p&gt;Umbraco is the most powerful and flexible CMS I have ever seen so far. I just write this essay to demonstrate how to develop an Umbraco DataType for the folks who have basic Asp.net development knowledge.&lt;/p&gt; &lt;p&gt;Here we go, outlines for the steps.&lt;/p&gt; &lt;ol&gt; &lt;li&gt;Create an Asp.net application project  &lt;li&gt;Add reference to umbraco.editorControls.dll  &lt;li&gt;Add the usercontrol  &lt;li&gt;Copy the dll and ascx to Umbraco site  &lt;li&gt;Run in Umbraco site&lt;/li&gt;&lt;/ol&gt; &lt;p&gt;&lt;strong&gt;1. Create an Asp.net Application project&lt;/strong&gt;&lt;/p&gt; &lt;p&gt;&lt;a href="http://images.cnblogs.com/cnblogs_com/czy/201204/201204221829348027.png"&gt;&lt;img style="background-image: none; border-bottom: 0px; border-left: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top: 0px; border-right: 0px; padding-top: 0px" title="image" border="0" alt="image" src="http://images.cnblogs.com/cnblogs_com/czy/201204/201204221829352520.png" width="602" height="431"&gt;&lt;/a&gt;&lt;/p&gt; &lt;p&gt;The purpose of the Asp.net application project is to debug the usercontrol directly. It is not convenient if you try to debug your usercontrol in Umbraco site environment. It is recommended to name of the project as that you expect in the deployment. Let’s say, the expected assembly name is “NovaDev3.UmbracoComponents”. We name the Asp.net application project “NovaDev3.UmbracoComponents”.&lt;/p&gt; &lt;p&gt;Then create a folder named “usercontrols” in the project. You will find that umbraco site probe the *.ascx file in “usercontrols” folder as well. You created usercontrol will be put in this folder.&lt;/p&gt; &lt;p&gt;&lt;a href="http://images.cnblogs.com/cnblogs_com/czy/201204/201204221829351997.png"&gt;&lt;img style="background-image: none; border-bottom: 0px; border-left: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top: 0px; border-right: 0px; padding-top: 0px" title="image" border="0" alt="image" src="http://images.cnblogs.com/cnblogs_com/czy/201204/201204221829353982.png" width="327" height="310"&gt;&lt;/a&gt;&lt;/p&gt; &lt;p&gt;&amp;nbsp;&lt;/p&gt; &lt;p&gt;&lt;strong&gt;2. Add reference to umbraco.editorControls.dll&lt;/strong&gt;&lt;/p&gt; &lt;p&gt;You can add the reference of umbraco.editorContorls.dll from your umbraco site/bin folder directly. We will implement umbraco.editorControls.userControlGrapper.IUsercontrolDataEditor when we create the usercontrol for the umbraco site. IUsercontrolDataEditor has only one property defined and you could ignore it at all if you don’t plan to save the value in the umbraco db.&lt;/p&gt; &lt;p&gt;&amp;nbsp;&lt;/p&gt;&lt;span class="kwrd"&gt;namespace&lt;/span&gt; umbraco.editorControls.userControlGrapper&lt;br/&gt;{&lt;br/&gt;    &lt;span class="kwrd"&gt;public&lt;/span&gt; &lt;span class="kwrd"&gt;interface&lt;/span&gt; IUsercontrolDataEditor&lt;br/&gt;    {&lt;br/&gt;        &lt;span class="kwrd"&gt;object&lt;/span&gt; &lt;span class="kwrd"&gt;value&lt;/span&gt; { get; set; }&lt;br/&gt;    }&lt;br/&gt;}&lt;style type="text/css"&gt;.csharpcode, .csharpcode pre{font-size: small;color: black;font-family: consolas, "Courier New", courier, monospace;background-color: #ffffff;/*white-space: pre;*/}.csharpcode pre { margin: 0em; }.csharpcode .rem { color: #008000; }.csharpcode .kwrd { color: #0000ff; }.csharpcode .str { color: #006080; }.csharpcode .op { color: #0000c0; }.csharpcode .preproc { color: #cc6633; }.csharpcode .asp { background-color: #ffff00; }.csharpcode .html { color: #800000; }.csharpcode .attr { color: #ff0000; }.csharpcode .alt {background-color: #f4f4f4;width: 100%;margin: 0em;}.csharpcode .lnum { color: #606060; }&lt;/style&gt;&lt;p&gt;&amp;nbsp;&lt;/p&gt;&lt;p&gt;&lt;strong&gt;3. Add the usercontrol &lt;/strong&gt;&lt;/p&gt;&lt;p&gt;Let’s add the usercontrol named “InventoryItemCategories”. It is recommended to follow umbraco naming convention that use camel style to name the control. The difference between normal asp.net usercontrol and the umbraco-featured user control is the implementation of &lt;font color="#666666"&gt;I&lt;/font&gt;&lt;span style="color: #2b91af"&gt;&lt;font color="#666666"&gt;UsercontrolDataEditor.&lt;/font&gt;&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;a href="http://images.cnblogs.com/cnblogs_com/czy/201204/201204221829355095.png"&gt;&lt;img style="background-image: none; border-bottom: 0px; border-left: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top: 0px; border-right: 0px; padding-top: 0px" title="image" border="0" alt="image" src="http://images.cnblogs.com/cnblogs_com/czy/201204/201204221829369031.png" width="368" height="504"&gt;&lt;/a&gt;&lt;/p&gt;&lt;p&gt;Let’s just add some simple code to categoriesControl and add it to Default.aspx to test.&lt;/p&gt;&lt;p&gt;&lt;strong&gt;categoriesControl.ascx&lt;/strong&gt;&lt;/p&gt;&lt;span style="background: yellow"&gt;&amp;lt;%&lt;/span&gt;&lt;span style="color: blue"&gt;@ &lt;/span&gt;&lt;span style="color: maroon"&gt;Control &lt;/span&gt;&lt;span style="color: red"&gt;Language&lt;/span&gt;&lt;span style="color: blue"&gt;="C#" &lt;/span&gt;&lt;span style="color: red"&gt;AutoEventWireup&lt;/span&gt;&lt;span style="color: blue"&gt;="true" &lt;/span&gt;&lt;span style="color: red"&gt;CodeBehind&lt;/span&gt;&lt;span style="color: blue"&gt;="categoriesControl.ascx.cs" &lt;/span&gt;&lt;span style="color: red"&gt;Inherits&lt;/span&gt;&lt;span style="color: blue"&gt;="NovaDev3.UmbracoComponents.usercontrols.categoriesControl" &lt;/span&gt;&lt;span style="background: yellow"&gt;%&amp;gt;&lt;br/&gt;&lt;/span&gt;&lt;span style="color: blue"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: maroon"&gt;asp&lt;/span&gt;&lt;span style="color: blue"&gt;:&lt;/span&gt;&lt;span style="color: maroon"&gt;DropDownList &lt;/span&gt;&lt;span style="color: red"&gt;ID&lt;/span&gt;&lt;span style="color: blue"&gt;="categoriesDropdown" &lt;/span&gt;&lt;span style="color: red"&gt;runat&lt;/span&gt;&lt;span style="color: blue"&gt;="server" /&amp;gt;&lt;br/&gt;&lt;/span&gt;&lt;p&gt;&amp;nbsp;&lt;/p&gt;&lt;p&gt;&lt;strong&gt;categoriesControl.cs&lt;/strong&gt;&lt;/p&gt;&lt;span style="color: blue"&gt;using &lt;/span&gt;System;&lt;br/&gt;&lt;span style="color: blue"&gt;using &lt;/span&gt;System.Collections.Generic;&lt;br/&gt;&lt;span style="color: blue"&gt;using &lt;/span&gt;System.Linq;&lt;br/&gt;&lt;span style="color: blue"&gt;using &lt;/span&gt;System.Web;&lt;br/&gt;&lt;span style="color: blue"&gt;using &lt;/span&gt;System.Web.UI;&lt;br/&gt;&lt;span style="color: blue"&gt;using &lt;/span&gt;System.Web.UI.WebControls;&lt;br/&gt;&lt;span style="color: blue"&gt;using &lt;/span&gt;umbraco.editorControls.userControlGrapper;&lt;br/&gt;&lt;br/&gt;&lt;span style="color: blue"&gt;namespace &lt;/span&gt;NovaDev3.UmbracoComponents.usercontrols&lt;br/&gt;{&lt;br/&gt;    &lt;span style="color: blue"&gt;public partial class &lt;/span&gt;&lt;span style="color: #2b91af"&gt;categoriesControl &lt;/span&gt;: System.Web.UI.&lt;span style="color: #2b91af"&gt;UserControl&lt;/span&gt;, &lt;span style="color: #2b91af"&gt;IUsercontrolDataEditor&lt;br/&gt;    &lt;/span&gt;{&lt;br/&gt;        &lt;span style="color: blue"&gt;protected void &lt;/span&gt;Page_Load(&lt;span style="color: blue"&gt;object &lt;/span&gt;sender, &lt;span style="color: #2b91af"&gt;EventArgs &lt;/span&gt;e)&lt;br/&gt;        {&lt;br/&gt;            &lt;span style="color: blue"&gt;if &lt;/span&gt;(!IsPostBack)&lt;br/&gt;            {&lt;br/&gt;                categoriesDropdown.DataSource = &lt;span style="color: blue"&gt;new string&lt;/span&gt;[] { &lt;br/&gt;                    &lt;span style="color: #a31515"&gt;"Rental"&lt;/span&gt;,&lt;br/&gt;                    &lt;span style="color: #a31515"&gt;"Spa"&lt;/span&gt;,&lt;br/&gt;                    &lt;span style="color: #a31515"&gt;"Class"&lt;/span&gt;,&lt;br/&gt;                    &lt;span style="color: #a31515"&gt;"Dining"&lt;/span&gt;,&lt;br/&gt;                    &lt;span style="color: #a31515"&gt;"Retail"&lt;br/&gt;                &lt;/span&gt;};&lt;br/&gt;&lt;br/&gt;                categoriesDropdown.DataBind();&lt;br/&gt;            }&lt;br/&gt;        }&lt;br/&gt;&lt;br/&gt;        &lt;span style="color: blue"&gt;public object &lt;/span&gt;value&lt;br/&gt;        {&lt;br/&gt;            &lt;span style="color: blue"&gt;get&lt;br/&gt;            &lt;/span&gt;{&lt;br/&gt;                &lt;span style="color: blue"&gt;return string&lt;/span&gt;.Empty;&lt;br/&gt;            }&lt;br/&gt;            &lt;span style="color: blue"&gt;set&lt;br/&gt;            &lt;/span&gt;{&lt;br/&gt;                &lt;span style="color: green"&gt;//do nothing&lt;br/&gt;            &lt;/span&gt;}&lt;br/&gt;        }&lt;br/&gt;    }&lt;br/&gt;}&lt;br/&gt;&lt;strong&gt;&lt;font face="Verdana"&gt;Default.aspx&lt;/font&gt;&lt;/strong&gt;&lt;font color="#666666"&gt;&lt;span style="background: yellow"&gt;&amp;lt;%&lt;/span&gt;&lt;span style="color: blue"&gt;@ &lt;/span&gt;&lt;span style="color: maroon"&gt;Page &lt;/span&gt;&lt;span style="color: red"&gt;Title&lt;/span&gt;&lt;span style="color: blue"&gt;="Home Page" &lt;/span&gt;&lt;span style="color: red"&gt;Language&lt;/span&gt;&lt;span style="color: blue"&gt;="C#" &lt;/span&gt;&lt;span style="color: red"&gt;MasterPageFile&lt;/span&gt;&lt;span style="color: blue"&gt;="~/Site.master" &lt;/span&gt;&lt;span style="color: red"&gt;AutoEventWireup&lt;/span&gt;&lt;/font&gt;&lt;font color="#666666"&gt;&lt;span style="color: blue"&gt;="true"&lt;br/&gt;    &lt;/span&gt;&lt;span style="color: red"&gt;CodeBehind&lt;/span&gt;&lt;span style="color: blue"&gt;="Default.aspx.cs" &lt;/span&gt;&lt;span style="color: red"&gt;Inherits&lt;/span&gt;&lt;span style="color: blue"&gt;="NovaDev3.UmbracoComponents._Default" &lt;/span&gt;&lt;/font&gt;&lt;span style="background: yellow"&gt;&lt;font color="#666666"&gt;%&amp;gt;&lt;/font&gt;&lt;br/&gt;&lt;strong&gt;&amp;lt;%&lt;/strong&gt;&lt;/span&gt;&lt;strong&gt;&lt;span style="color: blue"&gt;@ &lt;/span&gt;&lt;span style="color: maroon"&gt;Register &lt;/span&gt;&lt;span style="color: red"&gt;TagPrefix&lt;/span&gt;&lt;span style="color: blue"&gt;="novaCtrl" &lt;/span&gt;&lt;span style="color: red"&gt;TagName&lt;/span&gt;&lt;span style="color: blue"&gt;="categoriesControl" &lt;/span&gt;&lt;span style="color: red"&gt;Src&lt;/span&gt;&lt;span style="color: blue"&gt;="~/usercontrols/categoriesControl.ascx" &lt;/span&gt;&lt;/strong&gt;&lt;span style="background: yellow"&gt;&lt;strong&gt;%&amp;gt;&lt;/strong&gt;&lt;br/&gt;&lt;br/&gt;&lt;/span&gt;&lt;span style="color: blue"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: maroon"&gt;asp&lt;/span&gt;&lt;span style="color: blue"&gt;:&lt;/span&gt;&lt;span style="color: maroon"&gt;Content &lt;/span&gt;&lt;span style="color: red"&gt;ID&lt;/span&gt;&lt;span style="color: blue"&gt;="HeaderContent" &lt;/span&gt;&lt;span style="color: red"&gt;runat&lt;/span&gt;&lt;span style="color: blue"&gt;="server" &lt;/span&gt;&lt;span style="color: red"&gt;ContentPlaceHolderID&lt;/span&gt;&lt;span style="color: blue"&gt;="HeadContent"&amp;gt;&lt;br/&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: maroon"&gt;asp&lt;/span&gt;&lt;span style="color: blue"&gt;:&lt;/span&gt;&lt;span style="color: maroon"&gt;Content&lt;/span&gt;&lt;span style="color: blue"&gt;&amp;gt;&lt;br/&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: maroon"&gt;asp&lt;/span&gt;&lt;span style="color: blue"&gt;:&lt;/span&gt;&lt;span style="color: maroon"&gt;Content &lt;/span&gt;&lt;span style="color: red"&gt;ID&lt;/span&gt;&lt;span style="color: blue"&gt;="BodyContent" &lt;/span&gt;&lt;span style="color: red"&gt;runat&lt;/span&gt;&lt;span style="color: blue"&gt;="server" &lt;/span&gt;&lt;span style="color: red"&gt;ContentPlaceHolderID&lt;/span&gt;&lt;span style="color: blue"&gt;="MainContent"&amp;gt;&lt;br/&gt;&lt;/span&gt;&lt;span style="color: blue"&gt;&lt;strong&gt;    &amp;lt;&lt;/strong&gt;&lt;/span&gt;&lt;span style="color: maroon"&gt;&lt;strong&gt;div&lt;/strong&gt;&lt;/span&gt;&lt;strong&gt;&lt;span style="color: blue"&gt;&amp;gt;&lt;br/&gt;        &amp;lt;&lt;/span&gt;&lt;span style="color: maroon"&gt;novaCtrl&lt;/span&gt;&lt;span style="color: blue"&gt;:&lt;/span&gt;&lt;span style="color: maroon"&gt;categoriesControl &lt;/span&gt;&lt;span style="color: red"&gt;ID&lt;/span&gt;&lt;span style="color: blue"&gt;="categories" &lt;/span&gt;&lt;span style="color: red"&gt;runat&lt;/span&gt;&lt;/strong&gt;&lt;strong&gt;&lt;span style="color: blue"&gt;="server" /&amp;gt;&lt;br/&gt;    &amp;lt;/&lt;/span&gt;&lt;span style="color: maroon"&gt;div&lt;/span&gt;&lt;/strong&gt;&lt;span style="color: blue"&gt;&lt;strong&gt;&amp;gt;&lt;/strong&gt;&lt;br/&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: maroon"&gt;asp&lt;/span&gt;&lt;span style="color: blue"&gt;:&lt;/span&gt;&lt;span style="color: maroon"&gt;Content&lt;/span&gt;&lt;span style="color: blue"&gt;&amp;gt;&lt;br/&gt;&lt;/span&gt;&lt;p&gt;&amp;nbsp;&lt;/p&gt;&lt;p&gt;When you run your Asp.net project, the dropdownlist display successfully as below.&lt;/p&gt;&lt;p&gt;&lt;a href="http://images.cnblogs.com/cnblogs_com/czy/201204/201204221829364048.png"&gt;&lt;img style="background-image: none; border-bottom: 0px; border-left: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top: 0px; border-right: 0px; padding-top: 0px" title="image" border="0" alt="image" src="http://images.cnblogs.com/cnblogs_com/czy/201204/201204221829367113.png" width="405" height="285"&gt;&lt;/a&gt;&lt;/p&gt;&lt;p&gt;You can develop usercontrol with complex business logic in this way for incremental coding and debugging in the asp.net application site.&lt;/p&gt;&lt;p&gt;&amp;nbsp;&lt;/p&gt;&lt;p&gt;&lt;strong&gt;4. Copy the dll and ascx to Umbraco site &lt;/strong&gt;&lt;/p&gt;&lt;p&gt;When you development completes, you can copy the dll and ascx to the umbraco site folder.&lt;/p&gt;&lt;ul&gt;&lt;li&gt;Copying NovaDev3.UmbracoComponents.dll and its dependency dlls to umbraco site/bin folder &lt;li&gt;Copying *.ascx files to umbraco site/usercontrols folder.&lt;/li&gt;&lt;/ul&gt;&lt;p&gt;It is recommended to write a copying bat to do it at the beginning of the development.&lt;/p&gt;&lt;p&gt;&amp;nbsp;&lt;/p&gt;&lt;p&gt;&lt;strong&gt;5. Run in Umbraco site&lt;/strong&gt;&lt;/p&gt;&lt;p&gt;Go to the Data Types node in the Developer section in umbraco backoffice after you copy the *.dll and *.adcx files to umbraco site folders. Create a datatype named “Categories” and select its render control&amp;nbsp; as “umbraco usercontrol wrapper”.&lt;/p&gt;&lt;p&gt;&lt;a href="http://images.cnblogs.com/cnblogs_com/czy/201204/201204221829369654.png"&gt;&lt;img style="background-image: none; border-bottom: 0px; border-left: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top: 0px; border-right: 0px; padding-top: 0px" title="image" border="0" alt="image" src="http://images.cnblogs.com/cnblogs_com/czy/201204/201204221829372195.png" width="961" height="240"&gt;&lt;/a&gt;&lt;/p&gt;&lt;p&gt;After you click "Save” button, the “Usercontrol” dropdown list appear under the Database datatype, and then select “categoriesControl.ascx”&lt;/p&gt;&lt;p&gt;&lt;a href="http://images.cnblogs.com/cnblogs_com/czy/201204/201204221829378640.png"&gt;&lt;img style="background-image: none; border-bottom: 0px; border-left: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top: 0px; border-right: 0px; padding-top: 0px" title="image" border="0" alt="image" src="http://images.cnblogs.com/cnblogs_com/czy/201204/201204221829375849.png" width="910" height="232"&gt;&lt;/a&gt;&lt;/p&gt;&lt;p&gt;Now, you have added the usercontrol&amp;nbsp; as an Umbraco datatype into Umbraco site successfully.&lt;/p&gt;&lt;p&gt;Let’s add a CategoriesPage document type(don’t select “Creating matching template” option) to hold the “Categories” datatype.&lt;/p&gt;&lt;p&gt;&lt;a href="http://images.cnblogs.com/cnblogs_com/czy/201204/201204221829385882.png"&gt;&lt;img style="background-image: none; border-bottom: 0px; border-left: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top: 0px; border-right: 0px; padding-top: 0px" title="image" border="0" alt="image" src="http://images.cnblogs.com/cnblogs_com/czy/201204/201204221829385915.png" width="854" height="416"&gt;&lt;/a&gt;&lt;/p&gt;&lt;p&gt;Then add a content of “CategoriesPage” to get the category dropdownlist you have just completed in the Asp.net application project.&lt;/p&gt;&lt;p&gt;&lt;a href="http://images.cnblogs.com/cnblogs_com/czy/201204/201204221829382360.png"&gt;&lt;img style="background-image: none; border-bottom: 0px; border-left: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top: 0px; border-right: 0px; padding-top: 0px" title="image" border="0" alt="image" src="http://images.cnblogs.com/cnblogs_com/czy/201204/201204221829398490.png" width="444" height="479"&gt;&lt;/a&gt;&lt;/p&gt;&lt;p&gt;&amp;nbsp;&lt;/p&gt;&lt;p&gt;Other considerations such as the database access layer and settings in the configuration file are ignored here. So you may have additional step to add the database connection string or dependency web service configuration to the web.config in the umbraco site if your usercontrol consumes data from database or other web services. &lt;/p&gt;&lt;p&gt;I will appreciate if you have any suggestions on the practices.&lt;/p&gt;&lt;p&gt;&amp;nbsp;&lt;/p&gt;&lt;p&gt;Please refer the source code at my &lt;a href="https://novaumbracodemo.codeplex.com/SourceControl/changeset/changes/dbc1c6e750c1" target="_blank"&gt;Code Plex&lt;/a&gt;&lt;/p&gt;&lt;p&gt;Supported by &lt;a href="http://www.novasoftware.com/Developer/Umbraco.aspx?utm_source=codeplex&amp;amp;utm_medium=post&amp;amp;utm_campaign=czy" target="_blank"&gt;Nova Umbraco&lt;/a&gt;&lt;/p&gt;&lt;img src="http://www.cnblogs.com/czy/aggbug/2465306.html?type=1" width="1" height="1" alt=""/&gt;&lt;p&gt;&lt;a href="http://www.cnblogs.com/czy/archive/2012/04/22/2465306.html" target="_blank"&gt;本文链接&lt;/a&gt;&lt;/p&gt;</content></entry><entry><id>http://www.cnblogs.com/czy/archive/2012/04/04/2432590.html</id><title type="text">Umbraco-Xsl-Development-Template</title><summary type="text">Recommended tools Visual Studio Express FoxeVisual StudioIt provides intelligence prompt for the xsl key words to facilitate the work on the xsl.FoxeIt provides a tree-nodes like view on the xml document to facilitate the navigation on the umbraco.config cache file.Template CodesWith the help ...</summary><published>2012-04-04T15:43:00Z</published><updated>2012-04-04T15:43:00Z</updated><author><name>曹宗颖</name><uri>http://www.cnblogs.com/czy/</uri></author><link rel="alternate" href="http://www.cnblogs.com/czy/archive/2012/04/04/2432590.html"/><link rel="alternate" type="text/html" href="http://www.cnblogs.com/czy/archive/2012/04/04/2432590.html"/><content type="html">&lt;p&gt;&lt;strong&gt;Recommended tools&lt;/strong&gt;&lt;/p&gt;&lt;ol&gt;    &lt;li&gt;Visual Studio Express&lt;/li&gt;    &lt;li&gt;Foxe&lt;/li&gt;&lt;/ol&gt;&lt;p&gt;&amp;nbsp;&lt;/p&gt;&lt;p&gt;&lt;strong&gt;Visual Studio&lt;/strong&gt;&lt;/p&gt;&lt;p&gt;It provides intelligence prompt for the xsl key words to facilitate the work on the xsl.&lt;/p&gt;&lt;p&gt;&lt;a href="http://images.cnblogs.com/cnblogs_com/czy/201204/2012040523505680.png"&gt;&lt;img style="border: 0px currentColor; padding-top: 0px; padding-right: 0px; padding-left: 0px; display: inline;background-image: none;" title="image" border="0" alt="image" src="http://images.cnblogs.com/cnblogs_com/czy/201204/201204052350562555.png" width="317" height="195" /&gt;&lt;/a&gt;&lt;/p&gt;&lt;p&gt;&lt;strong&gt;Foxe&lt;/strong&gt;&lt;/p&gt;&lt;p&gt;It provides a tree-nodes like view on the xml document to facilitate the navigation on the umbraco.config cache file.&lt;/p&gt;&lt;p&gt;&lt;a href="http://images.cnblogs.com/cnblogs_com/czy/201204/201204052350575520.png"&gt;&lt;img style="border: 0px currentColor; padding-top: 0px; padding-right: 0px; padding-left: 0px; display: inline;background-image: none;" title="image" border="0" alt="image" src="http://images.cnblogs.com/cnblogs_com/czy/201204/201204052350583851.png" width="1056" height="455" /&gt;&lt;/a&gt;&lt;/p&gt;&lt;p&gt;&lt;strong&gt;Template Codes&lt;/strong&gt;&lt;/p&gt;&lt;p&gt;&lt;strong&gt;&lt;/strong&gt;&lt;/p&gt;&lt;p&gt;With the help of the two utility, copy the following code to start your umbraco xslt development.&lt;/p&gt;&lt;p&gt;&amp;nbsp;&lt;/p&gt;&lt;p&gt;&amp;lt;?xml version="1.0" encoding="UTF-8"?&amp;gt;&lt;br /&gt;&amp;lt;!DOCTYPE xsl:stylesheet [&lt;br /&gt;&amp;nbsp; &amp;lt;!ENTITY nbsp "&amp;amp;#x00A0;"&amp;gt;&lt;br /&gt;]&amp;gt;&lt;br /&gt;&amp;lt;xsl:stylesheet&lt;br /&gt;&amp;nbsp; version="1.0"&lt;br /&gt;&amp;nbsp; xmlns:xsl="&lt;a href="http://www.w3.org/1999/XSL/Transform%22"&gt;http://www.w3.org/1999/XSL/Transform%22&lt;/a&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; xmlns:msxml="urn:schemas-microsoft-com:xslt"&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; xmlns:umbraco.library="urn:umbraco.library"&lt;br /&gt;&amp;nbsp; xmlns:Exslt.ExsltCommon="urn:Exslt.ExsltCommon" &lt;br /&gt;&amp;nbsp; xmlns:Exslt.ExsltDatesAndTimes="urn:Exslt.ExsltDatesAndTimes" &lt;br /&gt;&amp;nbsp; xmlns:Exslt.ExsltMath="urn:Exslt.ExsltMath" &lt;br /&gt;&amp;nbsp; xmlns:Exslt.ExsltRegularExpressions="urn:Exslt.ExsltRegularExpressions" &lt;br /&gt;&amp;nbsp; xmlns:Exslt.ExsltStrings="urn:Exslt.ExsltStrings" &lt;br /&gt;&amp;nbsp; xmlns:Exslt.ExsltSets="urn:Exslt.ExsltSets"&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; exclude-result-prefixes="msxml umbraco.library Exslt.ExsltCommon Exslt.ExsltDatesAndTimes Exslt.ExsltMath Exslt.ExsltRegularExpressions Exslt.ExsltStrings Exslt.ExsltSets "&amp;gt;&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;lt;xsl:output method="xml" omit-xml-declaration="yes"/&amp;gt;&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;lt;xsl:param name="currentPage"/&amp;gt;&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&amp;nbsp; &amp;lt;xsl:template match="/"&amp;gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;!--The code here--&amp;gt;&lt;br /&gt;&amp;nbsp; &amp;lt;/xsl:template&amp;gt;&lt;br /&gt;&amp;lt;/xsl:stylesheet&amp;gt;&lt;/p&gt;&lt;p&gt;&amp;nbsp;&lt;/p&gt;&lt;p&gt;The xslt file is stored in the ~/xslt/ folder. The target xml file is at ~/App_Data/umbraco.config.&lt;/p&gt;&lt;p&gt;&amp;nbsp;&lt;/p&gt;&lt;p&gt;The following key words are commonly used when you write the xsl. &lt;/p&gt;&lt;ol&gt;    &lt;li&gt;value-of&lt;/li&gt;    &lt;li&gt;select&lt;/li&gt;    &lt;li&gt;attribute&lt;/li&gt;    &lt;li&gt;for-each&lt;/li&gt;    &lt;li&gt;sort&lt;/li&gt;    &lt;li&gt;if&lt;/li&gt;&lt;/ol&gt;&lt;p&gt;The following key words are commonly used when you write the xsl.&lt;/p&gt;&lt;ol&gt;    &lt;li&gt;parent::*&lt;/li&gt;    &lt;li&gt;child::*&lt;/li&gt;    &lt;li&gt;[@attributeName expression]&lt;/li&gt;&lt;/ol&gt;&lt;p&gt;Have a fun in coding with xsl for umbraco.config.&lt;/p&gt;&lt;p&gt;&amp;nbsp;&lt;/p&gt;&lt;p&gt;Supported by &lt;a href="http://www.novasoftware.com/Developer/Umbraco.aspx?utm_source=codeplex&amp;amp;utm_medium=post&amp;amp;utm_campaign=czy" target="_blank"&gt;Nova Umbraco&lt;/a&gt;&lt;/p&gt;&lt;img src="http://www.cnblogs.com/czy/aggbug/2432590.html?type=1" width="1" height="1" alt=""/&gt;&lt;p&gt;&lt;a href="http://www.cnblogs.com/czy/archive/2012/04/04/2432590.html" target="_blank"&gt;本文链接&lt;/a&gt;&lt;/p&gt;</content></entry><entry><id>http://www.cnblogs.com/czy/archive/2012/04/01/2429469.html</id><title type="text">Umbraco-DataType-First-Glance</title><summary type="text">DataType plays important role in Umbraco if you dedicate to extend the power of Umbraco. For simplicity, the dependencies for DataType goes as following. From the skeleton like diagram above, we can easily think about how can DataType work essentially. The ISqlHelper tells us the way that Umbraco s.</summary><published>2012-04-01T15:32:00Z</published><updated>2012-04-01T15:32:00Z</updated><author><name>曹宗颖</name><uri>http://www.cnblogs.com/czy/</uri></author><link rel="alternate" href="http://www.cnblogs.com/czy/archive/2012/04/01/2429469.html"/><link rel="alternate" type="text/html" href="http://www.cnblogs.com/czy/archive/2012/04/01/2429469.html"/><content type="html">&lt;p&gt;DataType plays important role in Umbraco if you dedicate to extend the power of Umbraco.&lt;/p&gt; &lt;p&gt;For simplicity, the dependencies for DataType goes as following.&lt;/p&gt; &lt;p&gt;&lt;a href="http://images.cnblogs.com/cnblogs_com/czy/201204/201204012332142908.png"&gt;&lt;img style="border: 0px currentColor; padding-top: 0px; padding-right: 0px; padding-left: 0px; display: inline;background-image: none;" title="image" border="0" alt="image" src="http://images.cnblogs.com/cnblogs_com/czy/201204/201204012332148207.png" width="556" height="239" /&gt;&lt;/a&gt;&lt;/p&gt; &lt;p&gt;From the skeleton like diagram above, we can easily think about how can DataType work essentially. The ISqlHelper tells us the way that Umbraco saves the values into database. Control tells us the way Umbraco represents the data. XmlDocument/XmlNode tells us the relationship to xsl.&lt;/p&gt; &lt;p&gt;&amp;nbsp;&lt;/p&gt; &lt;p&gt;After we have a skeleton like imagination on how DataType works, let turn to the real design of DataType in Umbraco. &lt;/p&gt; &lt;p&gt;&lt;a href="http://images.cnblogs.com/cnblogs_com/czy/201204/201204012332157302.png"&gt;&lt;img style="border: 0px currentColor; padding-top: 0px; padding-right: 0px; padding-left: 0px; display: inline;background-image: none;" title="image" border="0" alt="image" src="http://images.cnblogs.com/cnblogs_com/czy/201204/201204012332154204.png" width="604" height="581" /&gt;&lt;/a&gt;&lt;/p&gt; &lt;p&gt;You have got the differences between your imagination and the real design on the DataType or you are still confused on the design? It doesn&amp;#8217;t matter. Here you get the point to go deeper in Umbraco.&lt;/p&gt;  &lt;p&gt;&amp;nbsp;&lt;/p&gt; &lt;p&gt;Supported by &lt;a href="http://www.novasoftware.com/Developer/Umbraco.aspx?utm_source=codeplex&amp;amp;utm_medium=post&amp;amp;utm_campaign=czy" target="_blank"&gt;Nova Umbraco&lt;/a&gt;&lt;/p&gt; &lt;img src="http://www.cnblogs.com/czy/aggbug/2429469.html?type=1" width="1" height="1" alt=""/&gt;&lt;p&gt;&lt;a href="http://www.cnblogs.com/czy/archive/2012/04/01/2429469.html" target="_blank"&gt;本文链接&lt;/a&gt;&lt;/p&gt;</content></entry><entry><id>http://www.cnblogs.com/czy/archive/2012/03/29/2424421.html</id><title type="text">Umbraco-Color Picker–Demo</title><summary type="text">DemoAllow the end user has ability to change the background color with pre-defined color.Steps1. Create a datatype named BackGroundColor.2. Select Color Picker as its render control and select Nvarchar as its Database datatype.3. Add the pre-defined colorsYou can add any number of colors as you wish</summary><published>2012-03-29T15:27:00Z</published><updated>2012-03-29T15:27:00Z</updated><author><name>曹宗颖</name><uri>http://www.cnblogs.com/czy/</uri></author><link rel="alternate" href="http://www.cnblogs.com/czy/archive/2012/03/29/2424421.html"/><link rel="alternate" type="text/html" href="http://www.cnblogs.com/czy/archive/2012/03/29/2424421.html"/><content type="html">&lt;p&gt;&lt;strong&gt;Demo&lt;/strong&gt;&lt;/p&gt;&lt;p&gt;Allow the end user has ability to change the background color with pre-defined color.&lt;/p&gt;&lt;p&gt;&lt;strong&gt;Steps&lt;/strong&gt;&lt;/p&gt;&lt;p&gt;&lt;strong&gt;1. Create a datatype named BackGroundColor.&lt;/strong&gt;&lt;/p&gt;&lt;p&gt;&lt;a href="http://images.cnblogs.com/cnblogs_com/czy/201203/201203292325198683.png"&gt;&lt;img style="border: 0px currentColor; padding-top: 0px; padding-right: 0px; padding-left: 0px; display: inline;background-image: none;" title="image" border="0" alt="image" src="http://images.cnblogs.com/cnblogs_com/czy/201203/201203292325283233.png" width="648" height="312" /&gt;&lt;/a&gt;&lt;/p&gt;&lt;p&gt;&amp;nbsp;&lt;/p&gt;&lt;p&gt;&lt;strong&gt;2. Select Color Picker as its render control and select Nvarchar as its Database datatype.&lt;/strong&gt;&lt;/p&gt;&lt;p&gt;&lt;a href="http://images.cnblogs.com/cnblogs_com/czy/201203/201203292325312346.png"&gt;&lt;img style="border: 0px currentColor; padding-top: 0px; padding-right: 0px; padding-left: 0px; display: inline;background-image: none;" title="image" border="0" alt="image" src="http://images.cnblogs.com/cnblogs_com/czy/201203/201203292325395698.png" width="588" height="226" /&gt;&lt;/a&gt;&lt;/p&gt;&lt;p&gt;&amp;nbsp;&lt;/p&gt;&lt;p&gt;&lt;strong&gt;3. Add the pre-defined colors&lt;/strong&gt;&lt;/p&gt;&lt;p&gt;&lt;a href="http://images.cnblogs.com/cnblogs_com/czy/201203/201203292325444057.png"&gt;&lt;img style="border: 0px currentColor; padding-top: 0px; padding-right: 0px; padding-left: 0px; display: inline;background-image: none;" title="image" border="0" alt="image" src="http://images.cnblogs.com/cnblogs_com/czy/201203/201203292325473411.png" width="534" height="367" /&gt;&lt;/a&gt;&lt;/p&gt;&lt;p&gt;You can add any number of colors as you wish.&lt;/p&gt;&lt;p&gt;&amp;nbsp;&lt;/p&gt;&lt;p&gt;&lt;strong&gt;4. Add the color to Generic Properties in the TextPage document type.&lt;/strong&gt;&lt;/p&gt;&lt;p&gt;&lt;a href="http://images.cnblogs.com/cnblogs_com/czy/201203/201203292325505589.png"&gt;&lt;img style="border: 0px currentColor; padding-top: 0px; padding-right: 0px; padding-left: 0px; display: inline;background-image: none;" title="image" border="0" alt="image" src="http://images.cnblogs.com/cnblogs_com/czy/201203/201203292325531114.png" width="1006" height="316" /&gt;&lt;/a&gt;&lt;/p&gt;&lt;p&gt;It is reasonable to place Content&amp;nbsp; BackGround Color in the Generic properties tab as it controls the content&amp;#8217;s background color.&lt;/p&gt;&lt;p&gt;&amp;nbsp;&lt;/p&gt;&lt;p&gt;&lt;strong&gt;5. Set the color in the content properties tab&lt;/strong&gt;&lt;/p&gt;&lt;p&gt;&lt;a href="http://images.cnblogs.com/cnblogs_com/czy/201203/201203292325584207.png"&gt;&lt;img style="border: 0px currentColor; padding-top: 0px; padding-right: 0px; padding-left: 0px; display: inline;background-image: none;" title="image" border="0" alt="image" src="http://images.cnblogs.com/cnblogs_com/czy/201203/201203292326011336.png" width="757" height="480" /&gt;&lt;/a&gt;&lt;/p&gt;&lt;p&gt;After 1 &amp;#8211; 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.&lt;/p&gt;&lt;p&gt;&amp;nbsp;&lt;/p&gt;&lt;p&gt;&lt;strong&gt;6. Apply the color in the template&lt;/strong&gt;&lt;/p&gt;&lt;p&gt;&lt;a href="http://images.cnblogs.com/cnblogs_com/czy/201203/201203292326175258.png"&gt;&lt;img style="border: 0px currentColor; padding-top: 0px; padding-right: 0px; padding-left: 0px; display: inline;background-image: none;" title="image" border="0" alt="image" src="http://images.cnblogs.com/cnblogs_com/czy/201203/20120329232621368.png" width="1154" height="322" /&gt;&lt;/a&gt;&lt;/p&gt;&lt;p&gt;The code finally looks like the following.&lt;/p&gt;&lt;blockquote style='border:2px solid #EFEFEF;color:#333333;padding:5px 10px;'&gt;&lt;p&gt;&amp;lt;div class="entry" style="background-color:#&lt;font color="#ff0000"&gt;&amp;lt;umbraco:Item field="contentBackGroundColor" runat="server" /&amp;gt;&lt;/font&gt;"&amp;gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;umbraco:item runat="server" field="bodyText"&amp;gt;&amp;lt;/umbraco:item&amp;gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;/div&amp;gt;&lt;br /&gt;&lt;/p&gt;&lt;/blockquote&gt;&lt;p&gt;&amp;nbsp;&lt;/p&gt;&lt;p&gt;&lt;strong&gt;7. See the effect.&lt;/strong&gt;&lt;/p&gt;&lt;p&gt;&lt;a href="http://images.cnblogs.com/cnblogs_com/czy/201203/201203292326253253.png"&gt;&lt;img style="border: 0px currentColor; padding-top: 0px; padding-right: 0px; padding-left: 0px; display: inline;background-image: none;" title="image" border="0" alt="image" src="http://images.cnblogs.com/cnblogs_com/czy/201203/201203292326349787.png" width="601" height="552" /&gt;&lt;/a&gt;&lt;/p&gt;&lt;p&gt;&amp;nbsp;&lt;/p&gt;&lt;p&gt;&lt;strong&gt;More knowledge&lt;/strong&gt;&lt;/p&gt;&lt;p&gt;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.&lt;/p&gt;&lt;p&gt;&amp;nbsp;&lt;/p&gt;&lt;p&gt;The source code is available at &lt;a href="https://novaumbracodemo.codeplex.com/SourceControl/changeset/changes/5bd86e28ac57" target="_blank"&gt;NovaUmbracoDemo&lt;/a&gt; in CodePlex.&lt;/p&gt;&lt;p&gt;Supported by &lt;a href="http://www.novasoftware.com/Developer/Umbraco.aspx?utm_source=codeplex&amp;amp;utm_medium=post&amp;amp;utm_campaign=czy" target="_blank"&gt;Nova Umbraco&lt;/a&gt;&lt;/p&gt;&lt;img src="http://www.cnblogs.com/czy/aggbug/2424421.html?type=1" width="1" height="1" alt=""/&gt;&lt;p&gt;&lt;a href="http://www.cnblogs.com/czy/archive/2012/03/29/2424421.html" target="_blank"&gt;本文链接&lt;/a&gt;&lt;/p&gt;</content></entry><entry><id>http://www.cnblogs.com/czy/archive/2012/03/21/2410774.html</id><title type="text">关于Hg的文件过滤</title><summary type="text">Hg是一个不错的源代码管理器。但是在进行源代码管理时，它会将所有的文件全部都列出来，很是烦恼。 最近发现其有一个ignore功能，可以将不需要纳入源代码管理的文件或者是（更灵活的方式）正则表达式统统过滤掉。 截图如下： 对任意还没有纳入hg源代码管理的文件点击右键，选择Ignore。你会看见如下窗体。 可以选择文件名方式过滤，也可以选择正则表达式方式过滤。 我目前使用的正则表达式为： 过滤掉某...</summary><published>2012-03-21T14:56:00Z</published><updated>2012-03-21T14:56:00Z</updated><author><name>曹宗颖</name><uri>http://www.cnblogs.com/czy/</uri></author><link rel="alternate" href="http://www.cnblogs.com/czy/archive/2012/03/21/2410774.html"/><link rel="alternate" type="text/html" href="http://www.cnblogs.com/czy/archive/2012/03/21/2410774.html"/><content type="html">&lt;p&gt;Hg是一个不错的源代码管理器。但是在进行源代码管理时，它会将所有的文件全部都列出来，很是烦恼。&lt;/p&gt; &lt;p&gt;最近发现其有一个ignore功能，可以将不需要纳入源代码管理的文件或者是（更灵活的方式）正则表达式统统过滤掉。&lt;/p&gt; &lt;p&gt;截图如下：&lt;/p&gt; &lt;p&gt;&lt;a href="http://images.cnblogs.com/cnblogs_com/czy/201203/201203212255558913.png"&gt;&lt;img style="background-image: none; border-bottom: 0px; border-left: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top: 0px; border-right: 0px; padding-top: 0px" title="image" border="0" alt="image" src="http://images.cnblogs.com/cnblogs_com/czy/201203/201203212255552784.png" width="644" height="421"&gt;&lt;/a&gt;&lt;/p&gt; &lt;p&gt;对任意还没有纳入hg源代码管理的文件点击右键，选择Ignore。你会看见如下窗体。&lt;/p&gt; &lt;p&gt;&lt;a href="http://images.cnblogs.com/cnblogs_com/czy/201203/20120321225555799.png"&gt;&lt;img style="background-image: none; border-bottom: 0px; border-left: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top: 0px; border-right: 0px; padding-top: 0px" title="image" border="0" alt="image" src="http://images.cnblogs.com/cnblogs_com/czy/201203/20120321225556210.png" width="644" height="445"&gt;&lt;/a&gt;&lt;/p&gt; &lt;p&gt;可以选择文件名方式过滤，也可以选择正则表达式方式过滤。&lt;/p&gt; &lt;p&gt;我目前使用的正则表达式为：&lt;/p&gt; &lt;p&gt;过滤掉某一个目录下的所有文件：&lt;/p&gt; &lt;p&gt;uComponentsDemo/App_Data/preview/[\w\d.\-_]+&lt;/p&gt;  &lt;p&gt;过滤掉指定扩展名的文件：&lt;/p&gt; &lt;p&gt;[\w\d./_\-]+\.(pdb|dll|exe|cache|txt|suo|resources|rar|tlog|csv|bat)&lt;/p&gt;&lt;img src="http://www.cnblogs.com/czy/aggbug/2410774.html?type=1" width="1" height="1" alt=""/&gt;&lt;p&gt;&lt;a href="http://www.cnblogs.com/czy/archive/2012/03/21/2410774.html" target="_blank"&gt;本文链接&lt;/a&gt;&lt;/p&gt;</content></entry><entry><id>http://www.cnblogs.com/czy/archive/2012/03/11/2389944.html</id><title type="text">TeamView 有更新</title><summary type="text">TeamView有更新，下载地址 http://teamview.codeplex.com/ 问：TeamView是什么？ 答：一个处于概念阶段的项目进度管理系统。 问：什么叫概念阶段？ 答：即设计上满足了抽象概念的实现，但离产品级还有很长的路要走。例如，要让当前的发布在你的系统上运行起来，你的自己去配置数据库；当多个用户一同使用时，没有用户权限的限制。 问：它的核心价值是什么 答：从时间消...</summary><published>2012-03-11T03:56:00Z</published><updated>2012-03-11T03:56:00Z</updated><author><name>曹宗颖</name><uri>http://www.cnblogs.com/czy/</uri></author><link rel="alternate" href="http://www.cnblogs.com/czy/archive/2012/03/11/2389944.html"/><link rel="alternate" type="text/html" href="http://www.cnblogs.com/czy/archive/2012/03/11/2389944.html"/><content type="html">&lt;p&gt;TeamView有更新，下载地址&lt;/p&gt; &lt;p&gt;&lt;a title="http://teamview.codeplex.com/" href="http://teamview.codeplex.com/"&gt;http://teamview.codeplex.com/&lt;/a&gt;&lt;/p&gt; &lt;p&gt;&amp;nbsp;&lt;/p&gt; &lt;p&gt;问：TeamView是什么？&lt;/p&gt; &lt;p&gt;答：一个处于概念阶段的项目进度管理系统。&lt;/p&gt; &lt;p&gt;&amp;nbsp;&lt;/p&gt; &lt;p&gt;问：什么叫概念阶段？&lt;/p&gt; &lt;p&gt;答：即设计上满足了抽象概念的实现，但离产品级还有很长的路要走。例如，要让当前的发布在你的系统上运行起来，你的自己去配置数据库；当多个用户一同使用时，没有用户权限的限制。&lt;/p&gt; &lt;p&gt;&amp;nbsp;&lt;/p&gt; &lt;p&gt;问：它的核心价值是什么&lt;/p&gt; &lt;p&gt;答：从时间消耗上来体现项目进度。例如，整个项目的总时间是多少，当前使用了多少时间，当前超时多少时间。&lt;/p&gt; &lt;p&gt;&amp;nbsp;&lt;/p&gt; &lt;p&gt;问：它怎么是英文的？&lt;/p&gt; &lt;p&gt;答：作者是100%的中国人。只是就职于外包公司，为了更加广泛的进行宣传，所以暂时用英文。其实也没有多少英文。&lt;/p&gt; &lt;p&gt;&amp;nbsp;&lt;/p&gt; &lt;p&gt;问：既然是开源的，可以加入自己的代码吗？&lt;/p&gt; &lt;p&gt;答：我是绝对欢迎你的贡献。&lt;/p&gt; &lt;p&gt;&amp;nbsp;&lt;/p&gt; &lt;div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px" id="scid:66721397-FF69-4ca6-AEC4-17E6B3208830:8608f185-f62c-49c1-89ff-27d48e639fd7" class="wlWriterEditableSmartContent"&gt;&lt;table border=0 cellspacing=0 cellpadding=0 style='outline:none;border-style:none;margin:0px;padding:0px;width:400px;border-collapse:collapse;' &gt;                     &lt;tr&gt;                        &lt;td colspan=2 style='outline:none;border-style:none;margin:0px;padding:5px 0px 5px 5px;width:157px;vertical-align:bottom;' &gt;                            &lt;a href="https://skydrive.live.com/redir.aspx?cid=fe0f25b05b14feff&amp;amp;page=play&amp;amp;resid=FE0F25B05B14FEFF!152&amp;amp;parid=FE0F25B05B14FEFF!151&amp;amp;type=1&amp;amp;Bsrc=Photomail&amp;amp;Bpub=SDX.Photos&amp;amp;authkey=!ANYlq5jS5yfvH3E" target="_blank" border="0" style="outline:none;border-style:none;margin:0px;padding:0px;"&gt;                                &lt;img style="outline:none;border-style:none;padding:0px;margin:0px;border:0px;background:none;background-image:none;vertical-align:bottom;" border="0" alt="View album" title="View album" width="157" height="157" src="http://images.cnblogs.com/cnblogs_com/czy/201203/201203111359197808.png" /&gt;&lt;/a&gt;                        &lt;/td&gt;                        &lt;td colspan=3 style='vertical-align:middle;margin:0px;padding:5px 5px 5px 0px;outline:none;border-style:none;width:223px' &gt;                            &lt;div style="margin-left:10px;top:-3%;" &gt;                                &lt;div style='width:223px;overflow:visible;'&gt;&lt;a style="text-decoration:none;" href="https://skydrive.live.com/redir.aspx?cid=fe0f25b05b14feff&amp;amp;page=browse&amp;amp;resid=FE0F25B05B14FEFF!151&amp;amp;type=5&amp;amp;authkey=!ANYlq5jS5yfvH3E&amp;amp;Bsrc=Photomail&amp;amp;Bpub=SDX.Photos" target="_blank"&gt;&lt;span  style="line-height:1.26em;padding:0px;width:223px;font-size:26pt;font-family:'Segoe UI', helvetica, arial, sans-serif;"  defaultText="Enter album name here"&gt;TEAMVIEW&lt;/span&gt;&lt;/a&gt;&lt;/div&gt;                                &lt;div style="padding:10px 0px 0px 0px;margin:0px;"&gt;                                   &lt;table border=0 cellspacing=0 cellpadding=0 style="margin:0px;padding:0px;outline:none;border-style:none;border-collapse:collapse;width:auto;"&gt;                                        &lt;tr&gt;                                            &lt;td style="vertical-align:top;outline:none;border-style:none;margin:0px;padding:10px 15px 6px 0px;"&gt;&lt;a href="https://skydrive.live.com/redir.aspx?cid=fe0f25b05b14feff&amp;amp;page=play&amp;amp;resid=FE0F25B05B14FEFF!151&amp;amp;type=5&amp;amp;authkey=!ANYlq5jS5yfvH3E&amp;amp;Bsrc=Photomail&amp;amp;Bpub=SDX.Photos" border="0" target="_blank" style="font-family:'Segoe UI', helvetica, arial, sans-serif;font-size:8pt;outline:none;border-style:none;text-decoration: none;padding:0px;margin:0px;"&gt;VIEW SLIDE SHOW&lt;/a&gt;&lt;/td&gt;                                            &lt;td style="vertical-align:top;outline:none;border-style:none;margin:0px;padding:10px 0px 6px 0px;"&gt;&lt;a href="https://skydrive.live.com/redir.aspx?cid=fe0f25b05b14feff&amp;amp;page=downloadphotos&amp;amp;resid=FE0F25B05B14FEFF!151&amp;amp;type=5&amp;amp;Bsrc=Photomail&amp;amp;Bpub=SDX.Photos&amp;amp;authkey=!ANYlq5jS5yfvH3E" border="0" target="_blank" style="font-family:'Segoe UI', helvetica, arial, sans-serif;font-size:8pt;outline:none;border-style:none;text-decoration: none;padding:0px;margin:0px;"&gt;DOWNLOAD ALL&lt;/a&gt;&lt;/td&gt;                                        &lt;/tr&gt;                                                                           &lt;/table&gt;                                                                                                     &lt;/div&gt;                                                            &lt;/div&gt;                        &lt;/td&gt;                     &lt;/tr&gt;                    &lt;tr&gt;&lt;td style='vertical-align:bottom;outline:none;border-style:none;padding:0px 5px 5px 5px;margin:0px;width:76px;height:76px;' &gt;&lt;a href="https://skydrive.live.com/redir.aspx?cid=fe0f25b05b14feff&amp;amp;page=play&amp;amp;resid=FE0F25B05B14FEFF!153&amp;amp;parid=FE0F25B05B14FEFF!151&amp;amp;type=1&amp;amp;Bsrc=Photomail&amp;amp;Bpub=SDX.Photos&amp;amp;authkey=!ANYlq5jS5yfvH3E" border="0" target="_blank" style="font-family:'Segoe UI', helvetica, arial, sans-serif;font-size:8pt;outline:none;border-style:none;text-decoration: none;padding:0px;margin:0px;"&gt;&lt;img style="outline:none;border-style:none;padding:0px;margin:0px;border:0px;background:none;background-image:none;vertical-align:bottom;" border="0" width="76" alt="View album" title="View album" height="76" src="http://images.cnblogs.com/cnblogs_com/czy/201203/201203111359204744.png" /&gt;&lt;/a&gt;&lt;/td&gt;&lt;td style='vertical-align:bottom;outline:none;border-style:none;padding:0px 5px 5px 0px;margin:0px;width:76px;height:76px;' &gt;&lt;a href="https://skydrive.live.com/redir.aspx?cid=fe0f25b05b14feff&amp;amp;page=play&amp;amp;resid=FE0F25B05B14FEFF!154&amp;amp;parid=FE0F25B05B14FEFF!151&amp;amp;type=1&amp;amp;Bsrc=Photomail&amp;amp;Bpub=SDX.Photos&amp;amp;authkey=!ANYlq5jS5yfvH3E" border="0" target="_blank" style="font-family:'Segoe UI', helvetica, arial, sans-serif;font-size:8pt;outline:none;border-style:none;text-decoration: none;padding:0px;margin:0px;"&gt;&lt;img style="outline:none;border-style:none;padding:0px;margin:0px;border:0px;background:none;background-image:none;vertical-align:bottom;" border="0" width="76" alt="View album" title="View album" height="76" src="http://images.cnblogs.com/cnblogs_com/czy/201203/201203111359209727.png" /&gt;&lt;/a&gt;&lt;/td&gt;&lt;td style='vertical-align:bottom;outline:none;border-style:none;padding:0px 5px 5px 0px;margin:0px;width:76px;height:76px;' &gt;&lt;a href="https://skydrive.live.com/redir.aspx?cid=fe0f25b05b14feff&amp;amp;page=play&amp;amp;resid=FE0F25B05B14FEFF!155&amp;amp;parid=FE0F25B05B14FEFF!151&amp;amp;type=1&amp;amp;Bsrc=Photomail&amp;amp;Bpub=SDX.Photos&amp;amp;authkey=!ANYlq5jS5yfvH3E" border="0" target="_blank" style="font-family:'Segoe UI', helvetica, arial, sans-serif;font-size:8pt;outline:none;border-style:none;text-decoration: none;padding:0px;margin:0px;"&gt;&lt;img style="outline:none;border-style:none;padding:0px;margin:0px;border:0px;background:none;background-image:none;vertical-align:bottom;" border="0" width="76" alt="View album" title="View album" height="76" src="http://images.cnblogs.com/cnblogs_com/czy/201203/201203111359208299.png" /&gt;&lt;/a&gt;&lt;/td&gt;&lt;td style='vertical-align:bottom;outline:none;border-style:none;padding:0px 5px 5px 0px;margin:0px;width:76px;height:76px;' &gt;&lt;a href="https://skydrive.live.com/redir.aspx?cid=fe0f25b05b14feff&amp;amp;page=play&amp;amp;resid=FE0F25B05B14FEFF!156&amp;amp;parid=FE0F25B05B14FEFF!151&amp;amp;type=1&amp;amp;Bsrc=Photomail&amp;amp;Bpub=SDX.Photos&amp;amp;authkey=!ANYlq5jS5yfvH3E" border="0" target="_blank" style="font-family:'Segoe UI', helvetica, arial, sans-serif;font-size:8pt;outline:none;border-style:none;text-decoration: none;padding:0px;margin:0px;"&gt;&lt;img style="outline:none;border-style:none;padding:0px;margin:0px;border:0px;background:none;background-image:none;vertical-align:bottom;" border="0" width="76" alt="View album" title="View album" height="76" src="http://images.cnblogs.com/cnblogs_com/czy/201203/201203111359207186.png" /&gt;&lt;/a&gt;&lt;/td&gt;&lt;td style='vertical-align:bottom;outline:none;border-style:none;padding:0px 5px 5px 0px;margin:0px;width:76px;height:76px;' &gt;&amp;nbsp;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&lt;/div&gt;&lt;img src="http://www.cnblogs.com/czy/aggbug/2389944.html?type=1" width="1" height="1" alt=""/&gt;&lt;p&gt;&lt;a href="http://www.cnblogs.com/czy/archive/2012/03/11/2389944.html" target="_blank"&gt;本文链接&lt;/a&gt;&lt;/p&gt;</content></entry><entry><id>http://www.cnblogs.com/czy/archive/2012/01/10/2318150.html</id><title type="text">ObjectCache 的使用</title><summary type="text">Cache的获取及定义 Cache的获取代码: var cache = CacheManager.Instance.GetCache&lt;KeyType, ValueType&gt;(); 因此对Cache的定...</summary><published>2012-01-10T07:07:00Z</published><updated>2012-01-10T07:07:00Z</updated><author><name>曹宗颖</name><uri>http://www.cnblogs.com/czy/</uri></author><link rel="alternate" href="http://www.cnblogs.com/czy/archive/2012/01/10/2318150.html"/><link rel="alternate" type="text/html" href="http://www.cnblogs.com/czy/archive/2012/01/10/2318150.html"/><content type="html">&lt;p&gt;&lt;strong&gt;Cache的获取及定义&lt;/strong&gt;&lt;/p&gt; &lt;p&gt;Cache的获取代码:&lt;/p&gt; &lt;p&gt;var cache = CacheManager.Instance.GetCache&amp;lt;KeyType, ValueType&amp;gt;();&lt;/p&gt; &lt;p&gt;因此对Cache的定义，实际上就是对KeyType和ValueType的定义，例如：&lt;/p&gt;&lt;span class="kwrd"&gt;class&lt;/span&gt; Key :IEquatable&amp;lt;Key&amp;gt;&lt;br/&gt;&lt;br/&gt;{&lt;br/&gt;&lt;br/&gt;&lt;span class="kwrd"&gt;public&lt;/span&gt; &lt;span class="kwrd"&gt;string&lt;/span&gt; Id{get;set;}&lt;br/&gt;&lt;br/&gt;&lt;span class="kwrd"&gt;public&lt;/span&gt; &lt;span class="kwrd"&gt;bool&lt;/span&gt; Equals(Key other)&lt;br/&gt;&lt;br/&gt;{&lt;br/&gt;&lt;br/&gt;   &lt;span class="kwrd"&gt;if&lt;/span&gt;(other == &lt;span class="kwrd"&gt;null&lt;/span&gt;)&lt;br/&gt;&lt;br/&gt;      &lt;span class="kwrd"&gt;return&lt;/span&gt; &lt;span class="kwrd"&gt;false&lt;/span&gt;;&lt;br/&gt;&lt;br/&gt;   &lt;span class="kwrd"&gt;return&lt;/span&gt; Id == other.Id;&lt;br/&gt;&lt;br/&gt;}&lt;br/&gt;&lt;br/&gt;&lt;br/&gt;&lt;br/&gt;&lt;span class="kwrd"&gt;class&lt;/span&gt; BusinessObj&lt;br/&gt;&lt;br/&gt;{&lt;br/&gt;&lt;br/&gt;       &lt;span class="rem"&gt;/* property definitions*/&lt;/span&gt;&lt;br/&gt;&lt;br/&gt;}&lt;br/&gt;&lt;br/&gt;&lt;style type="text/css"&gt;.csharpcode, .csharpcode pre{font-size: small;color: black;font-family: consolas, "Courier New", courier, monospace;background-color: #ffffff;/*white-space: pre;*/}.csharpcode pre { margin: 0em; }.csharpcode .rem { color: #008000; }.csharpcode .kwrd { color: #0000ff; }.csharpcode .str { color: #006080; }.csharpcode .op { color: #0000c0; }.csharpcode .preproc { color: #cc6633; }.csharpcode .asp { background-color: #ffff00; }.csharpcode .html { color: #800000; }.csharpcode .attr { color: #ff0000; }.csharpcode .alt {background-color: #f4f4f4;width: 100%;margin: 0em;}.csharpcode .lnum { color: #606060; }&lt;/style&gt;&lt;p&gt;有了以上两个类型，我们就可以用来创建/获取cache了。&lt;/p&gt;&lt;p&gt;var cache = CacheManager.Instance.GetCache&amp;lt;Key, BusinessObj&amp;gt;();&lt;/p&gt;&lt;p&gt;&amp;nbsp;&lt;/p&gt;&lt;p&gt;&lt;strong&gt;Cache的作用范围&lt;/strong&gt;&lt;/p&gt;&lt;p&gt;由于Cache的定义实际上是通过强类型来定义的，如上面的代码GetCache&amp;lt;Key, BusinessObj&amp;gt;()。因此Cache的作用范围等同于上面定义的类型Key和BusinessObj的作用范围。&lt;/p&gt;&lt;p&gt;&lt;strong&gt;Cache生命周期的管理&lt;/strong&gt;&lt;/p&gt;&lt;p&gt;Cache生命周期的管理问题实际上就是控制cache的内容在何时失效。&lt;/p&gt;&lt;p&gt;有以下两种方式来控制cache内容何时失效，cache的内容一旦失效，它就会被从内存中移除&lt;/p&gt;&lt;p&gt;1. 可以通过继承BaseToken来管理&lt;/p&gt;&lt;p&gt;2. 直接调用ICache上的Reset()方法来清空Cache中的所有内容&lt;/p&gt;&lt;p&gt;3. 直接调用ICache上的Remove()方法来指定移除某一个CacheItem&lt;/p&gt;&lt;p&gt;&lt;strong&gt;Cache的分组&lt;/strong&gt;&lt;/p&gt;&lt;p&gt;对Cache分组的目的是，我们可以对同一组别的Cache进行清空处理。Cache的分组信息通过特性定义在Cache的Key上面。请参见以下代码：&lt;/p&gt;[CacheKeyCategory(2)]&lt;br/&gt;        &lt;span class="kwrd"&gt;class&lt;/span&gt; CackeKey2 : IEquatable&amp;lt;CackeKey2&amp;gt;&lt;br/&gt;        {&lt;br/&gt;            &lt;span class="kwrd"&gt;public&lt;/span&gt; &lt;span class="kwrd"&gt;long&lt;/span&gt; Id { get; set; }&lt;br/&gt;            &lt;span class="preproc"&gt;#region&lt;/span&gt; IEquatable&amp;lt;CacheKey&amp;gt; Members&lt;br/&gt;&lt;br/&gt;            &lt;span class="kwrd"&gt;public&lt;/span&gt; &lt;span class="kwrd"&gt;bool&lt;/span&gt; Equals(CackeKey2 other)&lt;br/&gt;            {&lt;br/&gt;                &lt;span class="kwrd"&gt;return&lt;/span&gt; Id == other.Id;&lt;br/&gt;            }&lt;br/&gt;&lt;br/&gt;            &lt;span class="preproc"&gt;#endregion&lt;/span&gt;&lt;br/&gt;        }&lt;p&gt;我们可以通过如下单元测试来看清楚其作用&lt;/p&gt;[TestMethod]&lt;br/&gt;        &lt;span class="kwrd"&gt;public&lt;/span&gt; &lt;span class="kwrd"&gt;void&lt;/span&gt; CacheCategory_Category_Test()&lt;br/&gt;        {&lt;br/&gt;            var cache = CacheManager.Instance.GetCache&amp;lt;CackeKey2, &lt;span class="kwrd"&gt;string&lt;/span&gt;&amp;gt;();&lt;br/&gt;            cache.GetWithCreate(&lt;span class="kwrd"&gt;new&lt;/span&gt; CackeKey2 { Id = 1 }, () =&amp;gt; &lt;span class="str"&gt;"Hello"&lt;/span&gt;, &lt;span class="kwrd"&gt;new&lt;/span&gt; BaseToken());&lt;br/&gt;&lt;br/&gt;            Assert.AreEqual(1, cache.Count());&lt;br/&gt;&lt;br/&gt;            CacheManager.Instance.ResetCaches(4);&lt;br/&gt;&lt;br/&gt;            Assert.AreEqual(1, cache.Count());&lt;br/&gt;&lt;br/&gt;            CacheManager.Instance.ResetCaches(2);&lt;br/&gt;&lt;br/&gt;            Assert.AreEqual(0, cache.Count());&lt;br/&gt;        }&lt;style type="text/css"&gt;.csharpcode, .csharpcode pre{font-size: small;color: black;font-family: consolas, "Courier New", courier, monospace;background-color: #ffffff;/*white-space: pre;*/}.csharpcode pre { margin: 0em; }.csharpcode .rem { color: #008000; }.csharpcode .kwrd { color: #0000ff; }.csharpcode .str { color: #006080; }.csharpcode .op { color: #0000c0; }.csharpcode .preproc { color: #cc6633; }.csharpcode .asp { background-color: #ffff00; }.csharpcode .html { color: #800000; }.csharpcode .attr { color: #ff0000; }.csharpcode .alt {background-color: #f4f4f4;width: 100%;margin: 0em;}.csharpcode .lnum { color: #606060; }&lt;/style&gt;当CacheManager.Instance.ResetCaches(4)被调用时,Cache&amp;lt;CacheKey2,string&amp;gt;中的内容并没有被清空。当 &lt;p&gt;CacheManager.Instance.ResetCaches(2)被调用时，Cache&amp;lt;CacheKey2,string&amp;gt;中的内容才被清空。&lt;/p&gt;&lt;p&gt;如果Cache的key没有添加分组信息，那么只有当CacheManager.Instance.ResetCaches（0）;被调用时，Cache中的内容才会被清空，且实际上，这是所有的缓存都会被清空。&lt;/p&gt;&lt;img src="http://www.cnblogs.com/czy/aggbug/2318150.html?type=1" width="1" height="1" alt=""/&gt;&lt;p&gt;&lt;a href="http://www.cnblogs.com/czy/archive/2012/01/10/2318150.html" target="_blank"&gt;本文链接&lt;/a&gt;&lt;/p&gt;</content></entry><entry><id>http://www.cnblogs.com/czy/archive/2012/01/06/2315266.html</id><title type="text">TDD 模式开发初探</title><summary type="text">以下是TDD开发中类型的一般分布 这里面关键的类型为 RequestUnitControl, RequestUnitModel, IConfigDataProvider和RequestUnitMod...</summary><published>2012-01-06T14:51:00Z</published><updated>2012-01-06T14:51:00Z</updated><author><name>曹宗颖</name><uri>http://www.cnblogs.com/czy/</uri></author><link rel="alternate" href="http://www.cnblogs.com/czy/archive/2012/01/06/2315266.html"/><link rel="alternate" type="text/html" href="http://www.cnblogs.com/czy/archive/2012/01/06/2315266.html"/><content type="html">&lt;p&gt;以下是TDD开发中类型的一般分布&lt;/p&gt; &lt;p&gt;&lt;a href="http://images.cnblogs.com/cnblogs_com/czy/201201/201201062250371795.png"&gt;&lt;img style="background-image: none; border-bottom: 0px; border-left: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top: 0px; border-right: 0px; padding-top: 0px" title="image_thumb1" border="0" alt="image_thumb1" src="http://images.cnblogs.com/cnblogs_com/czy/201201/201201062250386222.png" width="644" height="307"&gt;&lt;/a&gt;&lt;/p&gt; &lt;p&gt;这里面关键的类型为&lt;/p&gt; &lt;p&gt;RequestUnitControl, RequestUnitModel, IConfigDataProvider和RequestUnitModelTest&lt;/p&gt;  &lt;p&gt;RequestUnitControl:界面控件&lt;/p&gt; &lt;p&gt;RequestUnitModel:封装了RequestUnit的业务逻辑&lt;/p&gt; &lt;p&gt;IConfigDataProvider：获取Model中所需要的数据&lt;/p&gt; &lt;p&gt;RequestUnitModelTest：用于保证RequestUnitModel中封装的业务逻辑正确性的单元测试集合&lt;/p&gt;  &lt;p&gt;在TDD开发中，应该先在RequestUnitModelTest中添加业务逻辑的相关测试。然后开发从RequestUnitModelTest移到RequestUnitModel中。&lt;/p&gt; &lt;p&gt;相关的原则及方法，请参见&lt;/p&gt; &lt;p&gt;&lt;a href="http://www.cnblogs.com/czy/archive/2012/01/02/2310406.html"&gt;Thinking in Model in Windows Form development&lt;/a&gt;  &lt;p&gt; &lt;p&gt;另外，上面图表中还列出了SingleColumnDropDownGridExWrapper，这个类型用于简化RequestUnitControl中对Grid的使用，其思路类似于MVC中@Html中的那些helper方法。 &lt;/p&gt;&lt;img src="http://www.cnblogs.com/czy/aggbug/2315266.html?type=1" width="1" height="1" alt=""/&gt;&lt;p&gt;&lt;a href="http://www.cnblogs.com/czy/archive/2012/01/06/2315266.html" target="_blank"&gt;本文链接&lt;/a&gt;&lt;/p&gt;</content></entry><entry><id>http://www.cnblogs.com/czy/archive/2012/01/02/2310406.html</id><title type="text">Thinking in Model in Windows Form development</title><summary type="text">The Model is the M in MVC which is the current popular design pattern in Asp.net. To think in Model, I have two points. Model depends on the interfaces. Divide the business logic on the model into i...</summary><published>2012-01-02T13:20:00Z</published><updated>2012-01-02T13:20:00Z</updated><author><name>曹宗颖</name><uri>http://www.cnblogs.com/czy/</uri></author><link rel="alternate" href="http://www.cnblogs.com/czy/archive/2012/01/02/2310406.html"/><link rel="alternate" type="text/html" href="http://www.cnblogs.com/czy/archive/2012/01/02/2310406.html"/><content type="html">&lt;p&gt;The Model is the M in MVC which is the current popular design pattern in Asp.net. &lt;/p&gt; &lt;p&gt;To think in Model, I have two points.&lt;/p&gt; &lt;ol&gt; &lt;li&gt;Model depends on the interfaces.&amp;nbsp;&amp;nbsp; &lt;li&gt;Divide the business logic on the model into independent units. &lt;/li&gt;&lt;/ol&gt; &lt;p&gt;&lt;strong&gt;What’s the Problem to Be Addressed&lt;/strong&gt;&lt;/p&gt; &lt;p&gt;Although we have web services to hold the core business logic, there are quite a lot of bueinss logic in the client end to be coded mixed with the UI elements. This leads to testing, which launches the whole system to input or click, and finally distracts the programmer from testing the business logic itself.&lt;/p&gt; &lt;p&gt;This problem is outstanding in the recent development for the availability of child type. But the bugs are reported both in holding UI area and the drilldown UI area.&lt;/p&gt; &lt;p&gt;In addition, it is known that the UI is more changable than the business logic in the UI. Thus, we are commonly demanded by the end user to put the current existing UI element together or lead another UI style to implement the existing business logic. For example, the implementation in the Wizard and Lookbook mode which are error-prone and poorly maintained. &lt;/p&gt; &lt;p&gt;As the scale of the system grows, the complexity of the system may exponentially increase that may be awful to the maintenance.&lt;/p&gt; &lt;p&gt;So we have to make changes to cope with the complexity.&lt;/p&gt; &lt;p&gt;&lt;strong&gt;The Concepts in MVC&lt;/strong&gt;&lt;/p&gt; &lt;p&gt;The MVC design pattern is popular in Microsoft ASP.Net. It grows from Asp.net MVC to Asp.net MVC 4, which demonstrates the design pattern’s concepts are not only effective but also powful. The core concept in the MVC is to isolate the business logic from the influence in UI elements. So the programmer can concentrate on coding on the business logic and take unit test to guarantee its correctness directly instead of lauching the whole system to do the tedious inputting and clicking to test.&lt;/p&gt; &lt;p&gt;However, the MVC design pattern is implemented as a framework in ASP.net. So it is impossibile to introduce it into our windows form development environment.&lt;/p&gt; &lt;p&gt;The variation of MVC is MVP that has been implemented by Smart Client Software Factory(SCSF) in Microsfot platform. Considering the impact of introduction of SCSF to the current development, it would not be achieved in a short term.&lt;/p&gt; &lt;p&gt;So what we could do in short term is to introduce the concept into the development.&lt;/p&gt; &lt;p&gt;&lt;strong&gt;The Two Points as the Solution&lt;/strong&gt;&lt;/p&gt; &lt;p&gt;The tow points are involved in the Model. The Model should encapsulate the business logic of domain and it dosn’t have anything to do with the UI elements. So the Model can be depended by the UI area safely to respond the business logic from the UI elements consistently. I will explain the two points in the Model below.&lt;/p&gt; &lt;p&gt;&lt;strong&gt;Model depends on the interfaces&lt;/strong&gt;&lt;/p&gt; &lt;ol&gt; &lt;li&gt;The interface return the data requested in the Model to implement the business logic&lt;/li&gt; &lt;li&gt;The returned data from the interface can be mocked which is the important pre-condition for the unit test&lt;/li&gt; &lt;li&gt;The parameters in the methods of the interface should be as simple as possible to facilitate the mock process&lt;/li&gt; &lt;li&gt;The interface can be determined by the analysis on the domain of business logic. If the business logic is not involved the domain of business logic in the Model, you can hide it behind the interface. Another way to judge if the some business logic can be hidden by the interface is to see if the business logic can be unit tested in the Model.&lt;/li&gt;&lt;/ol&gt; &lt;p&gt;&lt;strong&gt;Divide the business logic on the Model into independent units&lt;/strong&gt;&lt;/p&gt; &lt;p&gt;Actually, the indpendent units are synonyms of public methods in the Model. This approach takes the following advantanges.&lt;/p&gt; &lt;ol&gt; &lt;li&gt;The aspects of the business logic on the Model can be expressed clearly&lt;/li&gt; &lt;li&gt;Each public method can be guarded by the series of unit tests to guarantee the correctness. &lt;/li&gt;&lt;/ol&gt; &lt;p&gt;To make the method can be guarded by unit test, they should take return-type to check the correctness in the unit test.&lt;/p&gt; &lt;p&gt;&amp;nbsp;&lt;/p&gt; &lt;p&gt;The goal of the two points is to help the programmers concentrate on the coding business logic and testing the correctness. And then, the container of the business logic can be invoked everywhere without differences. Eventually, the valuable point-the consistence of the business logic in multiple UI area is achieved. (The goal sounds very attractive&lt;img style="border-bottom-style: none; border-right-style: none; border-top-style: none; border-left-style: none" class="wlEmoticon wlEmoticon-smile" alt="微笑" src="http://images.cnblogs.com/cnblogs_com/czy/201201/201201022119391128.png"&gt;)&lt;/p&gt; &lt;p&gt;&amp;nbsp;&lt;/p&gt; &lt;p&gt;I will appreciate if you could send any of your feedback on the article.&lt;/p&gt; &lt;p&gt;Or please go to our company &lt;a href="http://www.novasoftware.com/Developer/CSharp.aspx?utm_source=thinkinginmodel&amp;amp;utm_medium=post&amp;amp;utm_campaign=czy%40vip.163.comium=post&amp;amp;utm_campaign=czy%40vip.163.com" target="_blank"&gt;novasoftware&lt;/a&gt; for more information.&lt;/p&gt;&lt;img src="http://www.cnblogs.com/czy/aggbug/2310406.html?type=1" width="1" height="1" alt=""/&gt;&lt;p&gt;&lt;a href="http://www.cnblogs.com/czy/archive/2012/01/02/2310406.html" target="_blank"&gt;本文链接&lt;/a&gt;&lt;/p&gt;</content></entry></feed>
