<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Prolific Notion &#187; .Net</title>
	<atom:link href="http://www.prolificnotion.co.uk/category/development/net/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.prolificnotion.co.uk</link>
	<description>Welcome to the miscellaneous mutterings of Simon Dingley, Certified Umbraco Developer</description>
	<lastBuildDate>Sun, 15 Jan 2012 08:06:04 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>DataType Support in uSiteBuilder for Umbraco</title>
		<link>http://www.prolificnotion.co.uk/datatype-support-in-usitebuilder-for-umbraco/</link>
		<comments>http://www.prolificnotion.co.uk/datatype-support-in-usitebuilder-for-umbraco/#comments</comments>
		<pubDate>Thu, 22 Dec 2011 15:41:16 +0000</pubDate>
		<dc:creator>Simon Dingley</dc:creator>
				<category><![CDATA[.Net]]></category>
		<category><![CDATA[Development]]></category>
		<category><![CDATA[Feature]]></category>
		<category><![CDATA[Umbraco]]></category>

		<guid isPermaLink="false">http://www.prolificnotion.co.uk/?p=695</guid>
		<description><![CDATA[Adding DataType Support in uSiteBuilder for Umbraco. My initial contribution to the project and how to add my custom build to your own projects.<h3>Related Posts</h3>
<ol>
		<li><a href="http://www.prolificnotion.co.uk/umbraco-locate-nearest-node-with-specific-property/" rel="bookmark">Umbraco : Locate nearest node with specific property</a><!-- (6.1)--></li>
	</ol>


Related posts brought to you by <a href='http://yarpp.org'>Yet Another Related Posts Plugin</a>.]]></description>
			<content:encoded><![CDATA[<div class="tweetmeme_button" style="float: right; margin-left: 10px;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fwww.prolificnotion.co.uk%2Fdatatype-support-in-usitebuilder-for-umbraco%2F"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fwww.prolificnotion.co.uk%2Fdatatype-support-in-usitebuilder-for-umbraco%2F&amp;style=normal&amp;service=bit.ly&amp;service_api=R_e35365ff035ed93fc3e67e6f868b7be3&amp;b=2" height="61" width="50" /><br />
			</a>
		</div>
<p>When I first discovered <a title="uSiteBuilder for Umbraco" href="http://our.umbraco.org/projects/developer-tools/usitebuilder" target="_blank"><strong>uSiteBuilder</strong> for <strong>Umbraco</strong></a> I knew right away that it was a game changer in the world of <strong><a title="Umbraco - The open source ASP.NET CMS " href="http://umbraco.com/" target="_blank">Umbraco</a></strong> development (for me at least!). I always felt a little uncomfortable about having to leave the relative safety of my IDE (Visual Studio 2010) and source control (Mercurial) to work in the browser when creating document types, wiring up templates and datatypes. uSiteBuilder is great because it allows you to take a code-first approach to your development allowing you to develop all of your document types, document type properties and templates with strongly typed code and take advantage of the benefits of any source/version control system you work within.</p>
<p>I guess I have been working with <strong>uSiteBuilder</strong> since earlier this year, shortly after it was released and it is the first dependency I now add to any new <strong><a title="Umbraco - The open source ASP.NET CMS " href="http://umbraco.com/" target="_blank">Umbraco</a> </strong>project. The only show stopper I&#8217;ve encountered rears it&#8217;s ugly head when working on a project with multiple developers and occurs when <strong>uSiteBuilder</strong> runs its synchronisation process and then throws an exception when it encounters a datatype on one of your document types that doesn&#8217;t exist in the target environment. The only real way around this is to <a href="http://our.umbraco.org/projects/developer-tools/usitebuilder/usitebuilder-support/26058-Multi-Developer-problem#comment96970" target="_blank">comment out</a> the offending document type property as recommended by <a title="Barry Fogarty - Umbraco Profile" href="http://our.umbraco.org/member/9909" target="_blank">Barry Fogarty</a>, rebuild and deploy your solution, create the missing datatype and then uncomment, rebuild and deploy again which is a pain and slows down development.</p>
<p>Those kind people over at <a title="Vega IT Sourcing is a software development outsourcing company from Novi Sad, Serbia" href="http://www.vegaitsourcing.rs/" target="_blank">Vega IT Sourcing</a> have released the <a title="uSiteBuilder is a framework made for .NET developers to simplify, speedup and take Umbraco development to next level" href="http://usitebuilder.codeplex.com/" target="_blank">source code for uSiteBuilder</a> which is great for people like me who like to have a go at plugging the gaps myself. So I pulled down the source code and made a custom build in an attempt to support at least the default datatypes for <strong>Umbraco</strong>. I have tried to follow the same logic as the rest of the project so you don&#8217;t really need to think too much about it and can quickly familiarise yourself with  the process for creating your datatypes in code. Here is an example of a custom datatype based on the TinyMCE Richtexteditor datatype in Umbraco:</p>
<pre class="brush: csharp; title: ; notranslate">
// --------------------------------------------------------------------------------------------------------------------
// &lt;copyright file=&quot;StandardContentEditor.cs&quot; company=&quot;Prolific Notion&quot;&gt;
//   (c) Copyright 2011 Prolific Notion, http://prolificnotion.co.uk
// &lt;/copyright&gt;
// &lt;summary&gt;
//   Defines the StandardContentEditor type.
// &lt;/summary&gt;
// --------------------------------------------------------------------------------------------------------------------

namespace MyUmbracoProject.Web.DataTypes
{
    using umbraco.cms.businesslogic.datatype;

    using Vega.USiteBuilder;

    /// &lt;summary&gt;
    /// Defines the Standard Content Editor Datatype
    /// &lt;/summary&gt;
    [DataType(
        UniqueId = &quot;{8AB81EFB-35F5-4EF0-9300-04A3AC8A2D21}&quot;,
        Name = &quot;Standard Content Editor&quot;,
        DatabaseDataType = DBTypes.Ntext,
        RenderControlGuid = &quot;5e9b75ae-face-41c8-b47e-5f4b0fd82f83&quot;)]
    public class StandardContentEditor : DataTypeBase
    {
    }
}
}</pre>
<p>Most of the attributes used here should be self explanatory however&#8230;</p>
<ol>
<li>UniqueId &#8211; A <em>unique</em> Guid for your datatype</li>
<li>Name &#8211; The name of your datatype. This is displayed in the Umbraco UI.</li>
<li>DatabaseDataType &#8211; This maps to the umbraco.cms.businesslogic.datatype.DBTypes Enum and defines the type of field to store data in the database.</li>
<li>RenderControlGuid &#8211; Defines the Guid of the control you would like to render for this datatype. In the example above &#8217;5e9b75ae-face-41c8-b47e-5f4b0fd82f83&#8242; is the Guid for the TinyMCE control.</li>
</ol>
<p>There is one other attribute not in the example above called &#8216;<em>RenderControlName</em>&#8216; which I am in two minds whether to keep or not. Essentially its purpose would be to try and find the control by name and therefore grab it&#8217;s Guid if the Guid attribute was not provided, any thoughts or comments on this appreciated however I think it may be subject to clashes or getting the wrong control because names do not have to be unique.</p>
<p>The only other thing you need to remember is to inherit from DataTypeBase.</p>
<p>I am very happy to have been accepted as a contributor on the uSiteBuilder project this week and hope that I can contribute some of my work into the next release. For now, if you are interested in trying out the build for my initial proof of concept you can <a href="http://usitebuilder.codeplex.com/SourceControl/list/changesets" target="_blank">grab it on CodePlex</a>, changset 84163. I welcome any feedback and comments.</p>
<h2>Where do we go from here?</h2>
<p>At this stage it&#8217;s really just a means of overcoming the exceptions I was previously encountering however I would ideally like to extend this to allow you to also configure your datatype settings in code so watch this space&#8230;!</p>
<h3>Related Posts</h3>
<ol>
		<li><a href="http://www.prolificnotion.co.uk/umbraco-locate-nearest-node-with-specific-property/" rel="bookmark">Umbraco : Locate nearest node with specific property</a><!-- (6.1)--></li>
	</ol>

<p>Related posts brought to you by <a href='http://yarpp.org'>Yet Another Related Posts Plugin</a>.</p>]]></content:encoded>
			<wfw:commentRss>http://www.prolificnotion.co.uk/datatype-support-in-usitebuilder-for-umbraco/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Register ASP.Net on IIS in Windows 7</title>
		<link>http://www.prolificnotion.co.uk/register-asp-net-on-iis-in-windows-7/</link>
		<comments>http://www.prolificnotion.co.uk/register-asp-net-on-iis-in-windows-7/#comments</comments>
		<pubDate>Tue, 03 Aug 2010 05:30:49 +0000</pubDate>
		<dc:creator>Simon Dingley</dc:creator>
				<category><![CDATA[.Net]]></category>
		<category><![CDATA[Development]]></category>
		<category><![CDATA[Windows 7]]></category>

		<guid isPermaLink="false">http://www.prolificnotion.co.uk/?p=423</guid>
		<description><![CDATA[
			
				
			
		
In IIS on Windows 7 it appears that the &#8216;old fashioned&#8217; method of using ASP.NET IIS Registration Tool (Aspnet_regiis.exe) is no longer the correct method to update the script maps. Instead the Windows feature should be enabled via the control panel by following the steps below:

Open the Control Panel
Select &#8220;Programs&#8221;
Select &#8220;Turn Windows Features on or [...]<h3>Related Posts</h3>
<ol>
		<li><a href="http://www.prolificnotion.co.uk/smtp-logging-on-windows-server-2008/" rel="bookmark">Setup SMTP Logging on Windows Server 2008 by enabling the ODBC Logging module</a><!-- (5.5)--></li>
	</ol>


Related posts brought to you by <a href='http://yarpp.org'>Yet Another Related Posts Plugin</a>.]]></description>
			<content:encoded><![CDATA[<div class="tweetmeme_button" style="float: right; margin-left: 10px;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fwww.prolificnotion.co.uk%2Fregister-asp-net-on-iis-in-windows-7%2F"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fwww.prolificnotion.co.uk%2Fregister-asp-net-on-iis-in-windows-7%2F&amp;style=normal&amp;service=bit.ly&amp;service_api=R_e35365ff035ed93fc3e67e6f868b7be3&amp;b=2" height="61" width="50" /><br />
			</a>
		</div>
<p>In IIS on Windows 7 it appears that the &#8216;old fashioned&#8217; method of using <a title="Update the script maps for an ASP.NET application to point to the ASP.NET ISAPI version that is associated with the tool" href="http://msdn.microsoft.com/en-us/library/k6h9cz8h(VS.80).aspx">ASP.NET IIS Registration Tool (Aspnet_regiis.exe)</a> is no longer the correct method to update the script maps. Instead the Windows feature should be enabled via the control panel by following the steps below:</p>
<ol>
<li>Open the Control Panel</li>
<li>Select &#8220;Programs&#8221;</li>
<li>Select &#8220;Turn Windows Features on or off&#8221;</li>
<li>Locate the following node:<br />
<strong>Internet Information Services</strong> &gt; <strong>World Wide Web Services</strong> &gt; <strong>Application Development Features</strong></li>
<li>Tick the box for <strong>ASP.NET</strong> and confirm.</li>
</ol>
<p><a href="http://www.prolificnotion.co.uk/wp-content/uploads/2010/08/iis-register-aspnet.png"><img title="Turn Windows Feature On/Off" src="http://www.prolificnotion.co.uk/wp-content/uploads/2010/08/iis-register-aspnet.png" alt="Turn Windows Feature On/Off" width="429" height="375" /></a></p>
<h3>Related Posts</h3>
<ol>
		<li><a href="http://www.prolificnotion.co.uk/smtp-logging-on-windows-server-2008/" rel="bookmark">Setup SMTP Logging on Windows Server 2008 by enabling the ODBC Logging module</a><!-- (5.5)--></li>
	</ol>

<p>Related posts brought to you by <a href='http://yarpp.org'>Yet Another Related Posts Plugin</a>.</p>]]></content:encoded>
			<wfw:commentRss>http://www.prolificnotion.co.uk/register-asp-net-on-iis-in-windows-7/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>C# Utility method to populate list controls with all countries as given in ISO 3166-1</title>
		<link>http://www.prolificnotion.co.uk/c-utility-method-to-populate-list-controls-with-all-countries-as-given-in-iso-3166-1/</link>
		<comments>http://www.prolificnotion.co.uk/c-utility-method-to-populate-list-controls-with-all-countries-as-given-in-iso-3166-1/#comments</comments>
		<pubDate>Fri, 23 Jul 2010 20:36:03 +0000</pubDate>
		<dc:creator>Simon Dingley</dc:creator>
				<category><![CDATA[.Net]]></category>
		<category><![CDATA[Development]]></category>

		<guid isPermaLink="false">http://www.prolificnotion.co.uk/?p=469</guid>
		<description><![CDATA[
			
				
			
		
Most projects I work on need a list of countries at some point so I put together a snippet of SQL that I could reuse to create and populate a countries table in the database with all countries as given in ISO 3166-1. After recently writing a utility class to populate list controls with world [...]<h3>Related Posts</h3>
<ol>
		<li><a href="http://www.prolificnotion.co.uk/c-utility-method-to-populate-list-controls-with-world-currencies/" rel="bookmark">C# Utility method to populate list controls with world currencies</a><!-- (38)--></li>
		<li><a href="http://www.prolificnotion.co.uk/ucommerce-for-umbraco-extension-method-iso-3166-numeric-country-codes/" rel="bookmark">UCommerce for Umbraco Extension Method &#8211; ISO 3166 Numeric Country Codes</a><!-- (10)--></li>
	</ol>


Related posts brought to you by <a href='http://yarpp.org'>Yet Another Related Posts Plugin</a>.]]></description>
			<content:encoded><![CDATA[<div class="tweetmeme_button" style="float: right; margin-left: 10px;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fwww.prolificnotion.co.uk%2Fc-utility-method-to-populate-list-controls-with-all-countries-as-given-in-iso-3166-1%2F"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fwww.prolificnotion.co.uk%2Fc-utility-method-to-populate-list-controls-with-all-countries-as-given-in-iso-3166-1%2F&amp;style=normal&amp;service=bit.ly&amp;service_api=R_e35365ff035ed93fc3e67e6f868b7be3&amp;b=2" height="61" width="50" /><br />
			</a>
		</div>
<p>Most projects I work on need a list of countries at some point so I put together a snippet of SQL that I could reuse to create and populate a countries table in the database with all countries as given in <a title="English country names and code elements" href="http://www.iso.org/iso/english_country_names_and_code_elements">ISO 3166-1</a>. After recently writing <a title="How to populate a ListControl with currency options" href="http://www.prolificnotion.co.uk/c-utility-method-to-populate-list-controls-with-world-currencies/">a utility class to populate list controls with world currencies</a> according to <a title="ISO 4217 currency and funds name and code elements" href="http://www.iso.org/iso/support/faqs/faqs_widely_used_standards/widely_used_standards_other/currency_codes/currency_codes_list-1.htm">ISO 4217</a> it got me wondering if I could also do the same for countries using only the .Net Framework. And so I came up with the following utility class to do the job.</p>
<pre class="brush: csharp; title: ; notranslate">        /// &lt;summary&gt;
        /// Populates the list control with countries as given by ISO 4217.
        /// &lt;/summary&gt;
        /// &lt;param name=&quot;ctrl&quot;&gt;The list control to populate.&lt;/param&gt;
        public static void FillWithISOCountries(ListControl ctrl)
        {
            foreach (CultureInfo cultureInfo in CultureInfo.GetCultures(CultureTypes.SpecificCultures))
            {
                RegionInfo regionInfo = new RegionInfo(cultureInfo.LCID);
                if (ctrl.Items.FindByValue(regionInfo.TwoLetterISORegionName) == null)
                {
                    ctrl.Items.Add(new ListItem(regionInfo.EnglishName, regionInfo.TwoLetterISORegionName));
                }
            }

            RegionInfo currentRegionInfo = new RegionInfo(CultureInfo.CurrentCulture.LCID);

            //- Default the selection to the current cultures country
            if (ctrl.Items.FindByValue(currentRegionInfo.TwoLetterISORegionName) != null)
            {
                ctrl.Items.FindByValue(currentRegionInfo.TwoLetterISORegionName).Selected = true;
            }
        }</pre>
<h3>Related Posts</h3>
<ol>
		<li><a href="http://www.prolificnotion.co.uk/c-utility-method-to-populate-list-controls-with-world-currencies/" rel="bookmark">C# Utility method to populate list controls with world currencies</a><!-- (38)--></li>
		<li><a href="http://www.prolificnotion.co.uk/ucommerce-for-umbraco-extension-method-iso-3166-numeric-country-codes/" rel="bookmark">UCommerce for Umbraco Extension Method &#8211; ISO 3166 Numeric Country Codes</a><!-- (10)--></li>
	</ol>

<p>Related posts brought to you by <a href='http://yarpp.org'>Yet Another Related Posts Plugin</a>.</p>]]></content:encoded>
			<wfw:commentRss>http://www.prolificnotion.co.uk/c-utility-method-to-populate-list-controls-with-all-countries-as-given-in-iso-3166-1/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
		<item>
		<title>C# Utility method to populate list controls with world currencies</title>
		<link>http://www.prolificnotion.co.uk/c-utility-method-to-populate-list-controls-with-world-currencies/</link>
		<comments>http://www.prolificnotion.co.uk/c-utility-method-to-populate-list-controls-with-world-currencies/#comments</comments>
		<pubDate>Thu, 06 May 2010 09:40:07 +0000</pubDate>
		<dc:creator>Simon Dingley</dc:creator>
				<category><![CDATA[.Net]]></category>
		<category><![CDATA[Development]]></category>

		<guid isPermaLink="false">http://www.prolificnotion.co.uk/?p=400</guid>
		<description><![CDATA[A requirement that came up recently required a drop down list of world currencies. I developed a reusable method for populating a ListControl with World Currencies using components from the .Net Framework alone.<h3>Related Posts</h3>
<ol>
		<li><a href="http://www.prolificnotion.co.uk/c-utility-method-to-populate-list-controls-with-all-countries-as-given-in-iso-3166-1/" rel="bookmark">C# Utility method to populate list controls with all countries as given in ISO 3166-1</a><!-- (37.6)--></li>
		<li><a href="http://www.prolificnotion.co.uk/ucommerce-for-umbraco-extension-method-iso-3166-numeric-country-codes/" rel="bookmark">UCommerce for Umbraco Extension Method &#8211; ISO 3166 Numeric Country Codes</a><!-- (6.6)--></li>
	</ol>


Related posts brought to you by <a href='http://yarpp.org'>Yet Another Related Posts Plugin</a>.]]></description>
			<content:encoded><![CDATA[<div class="tweetmeme_button" style="float: right; margin-left: 10px;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fwww.prolificnotion.co.uk%2Fc-utility-method-to-populate-list-controls-with-world-currencies%2F"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fwww.prolificnotion.co.uk%2Fc-utility-method-to-populate-list-controls-with-world-currencies%2F&amp;style=normal&amp;service=bit.ly&amp;service_api=R_e35365ff035ed93fc3e67e6f868b7be3&amp;b=2" height="61" width="50" /><br />
			</a>
		</div>
<p>I am working on a Job File System (JFS) for a client and they had the requirement to include a drop down list of currencies on their Purchase Order and Invoice documents, at first I was going to manually put together a list control but on reflection I thought their must be a better way of doing this that is more reusable. So here I have a utility method I put together to populate a ListControl with currency options. I would be interested in any feedback on this and alternative/better methods of achieving the end result:</p>
<pre class="brush: csharp; title: ; notranslate">
/// &lt;summary&gt;
/// Fills the ListControl with ISO currency symbols.
/// &lt;/summary&gt;
/// &lt;param name=&quot;ctrl&quot;&gt;The ListControl.&lt;/param&gt;
public static void FillWithISOCurrencySymbols(ListControl ctrl)
{
	foreach (CultureInfo cultureInfo in CultureInfo.GetCultures(CultureTypes.SpecificCultures))
	{
		RegionInfo regionInfo = new RegionInfo(cultureInfo.LCID);
		if (ctrl.Items.FindByValue(regionInfo.ISOCurrencySymbol) == null)
		{
			ctrl.Items.Add(new ListItem(regionInfo.CurrencyEnglishName, regionInfo.ISOCurrencySymbol));
		}
	}

	RegionInfo currentRegionInfo = new RegionInfo(CultureInfo.CurrentCulture.LCID);

	//- Default the selection to the current cultures currency symbol
	if (ctrl.Items.FindByValue(currentRegionInfo.ISOCurrencySymbol) != null)
	{
		ctrl.Items.FindByValue(currentRegionInfo.ISOCurrencySymbol).Selected = true;
	}
}
</pre>
<h3>Related Posts</h3>
<ol>
		<li><a href="http://www.prolificnotion.co.uk/c-utility-method-to-populate-list-controls-with-all-countries-as-given-in-iso-3166-1/" rel="bookmark">C# Utility method to populate list controls with all countries as given in ISO 3166-1</a><!-- (37.6)--></li>
		<li><a href="http://www.prolificnotion.co.uk/ucommerce-for-umbraco-extension-method-iso-3166-numeric-country-codes/" rel="bookmark">UCommerce for Umbraco Extension Method &#8211; ISO 3166 Numeric Country Codes</a><!-- (6.6)--></li>
	</ol>

<p>Related posts brought to you by <a href='http://yarpp.org'>Yet Another Related Posts Plugin</a>.</p>]]></content:encoded>
			<wfw:commentRss>http://www.prolificnotion.co.uk/c-utility-method-to-populate-list-controls-with-world-currencies/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Convert HTML to Plain Text in C# using Markdown</title>
		<link>http://www.prolificnotion.co.uk/convert-html-to-plain-text-in-c-using-markdown/</link>
		<comments>http://www.prolificnotion.co.uk/convert-html-to-plain-text-in-c-using-markdown/#comments</comments>
		<pubDate>Wed, 04 Nov 2009 13:41:12 +0000</pubDate>
		<dc:creator>Simon Dingley</dc:creator>
				<category><![CDATA[.Net]]></category>
		<category><![CDATA[Umbraco]]></category>
		<category><![CDATA[ASP.NET]]></category>

		<guid isPermaLink="false">http://www.prolificnotion.co.uk/?p=262</guid>
		<description><![CDATA[Creating a plain-text version of HTML that is suitable to be sent out as the text part of a multi-part email. Using C# and XSLT I have developed a working solution to the problem with help from a third party markdown XSLT file.<h3>Related Posts</h3>

No related posts.


Related posts brought to you by <a href='http://yarpp.org'>Yet Another Related Posts Plugin</a>.]]></description>
			<content:encoded><![CDATA[<div class="tweetmeme_button" style="float: right; margin-left: 10px;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fwww.prolificnotion.co.uk%2Fconvert-html-to-plain-text-in-c-using-markdown%2F"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fwww.prolificnotion.co.uk%2Fconvert-html-to-plain-text-in-c-using-markdown%2F&amp;style=normal&amp;service=bit.ly&amp;service_api=R_e35365ff035ed93fc3e67e6f868b7be3&amp;b=2" height="61" width="50" /><br />
			</a>
		</div>
<p>While working on my customisations to <a style="outline-style: none; outline-width: initial; outline-color: initial; color: #33707e; text-decoration: underline; padding: 0px; margin: 0px; border: 0px initial initial;" href="http://www.nibble.be/">Tim Geyssens</a> <a style="outline-style: none; outline-width: initial; outline-color: initial; color: #33707e; text-decoration: underline; padding: 0px; margin: 0px; border: 0px initial initial;" href="http://www.nibble.be/?p=63">MailEngine</a> I was looking for an accurate method of automatically creating a plain-text version of the HTML emails that were being sent out by the site. Further reading brought my attention to something called <a title="Read more about Markdown here" href="http://en.wikipedia.org/wiki/Markdown">Markdown</a>. After some hunting around with a little help from my friend Google I managed to find a markdown XSLT file. Using the XSLT I could transform my HTML email to plain-text with relative ease and accuracy. Of course in order to do this I would need a valid XML document and as my pages were already valid XHTML I had no problems there.</p>
<p>Here is my method for doing the conversion, all it requires is that you pass it the HTML you want to convert which must be valid XML:</p>
<pre class="brush: csharp; title: ; notranslate">/// &lt;summary&gt;
/// Converts to HTML to plain-text.
/// &lt;/summary&gt;
/// &lt;param name=&quot;HTML&quot;&gt;The HTML.&lt;/param&gt;
/// &lt;returns&gt;The plain text representation of the HTML&lt;/returns&gt;
private static string ConvertToText(string HTML)
{
    string text = string.Empty;

    XmlDocument xmlDoc = new XmlDocument();
    XmlDocument xsl = new XmlDocument();
    xmlDoc.LoadXml(HTML);
    xsl.CreateEntityReference(&quot;nbsp&quot;);
    xsl.Load(System.Web.HttpContext.Current.Server.MapPath(&quot;/xslt/Markdown.xslt&quot;));

    //creating xslt
    XslTransform xslt = new XslTransform();
    xslt.Load(xsl, null, null);

    //creating stringwriter
    StringWriter writer = new System.IO.StringWriter();

    //Transform the xml.
    xslt.Transform(xmlDoc, null, writer, null);

    //return string
    text = writer.ToString();
    writer.Close();

    return text;
}</pre>
<p>Download the XSLT file I used from here:</p>
<p><a href="http://symphony-cms.com/downloads/xslt/file/20573/">http://symphony-cms.com/downloads/xslt/file/20573/</a></p>
<p>I would love to hear from anyone that does this differently or if you can find any problems with the method I have chosen to implement for this solution.</p>
<h3>Related Posts</h3>
<p>No related posts.</p>

<p>Related posts brought to you by <a href='http://yarpp.org'>Yet Another Related Posts Plugin</a>.</p>]]></content:encoded>
			<wfw:commentRss>http://www.prolificnotion.co.uk/convert-html-to-plain-text-in-c-using-markdown/feed/</wfw:commentRss>
		<slash:comments>20</slash:comments>
		</item>
	</channel>
</rss>

