<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" media="screen" href="/~d/styles/rss2full.xsl"?><?xml-stylesheet type="text/css" media="screen" href="http://feeds.feedburner.com/~d/styles/itemcontent.css"?><rss 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/" xmlns:feedburner="http://rssnamespace.org/feedburner/ext/1.0" version="2.0">

<channel>
	<title>Frederik Vig - ASP.NET developer</title>
	
	<link>http://www.frederikvig.com</link>
	<description />
	<lastBuildDate>Sat, 27 Feb 2010 23:46:02 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.2</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="self" type="application/rss+xml" href="http://feeds.feedburner.com/frederikvig" /><feedburner:info uri="frederikvig" /><atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="hub" href="http://pubsubhubbub.appspot.com/" /><item>
		<title>Adding different CSS classes when using the EPiServer PageTree control</title>
		<link>http://feedproxy.google.com/~r/frederikvig/~3/LQlRQfOogeQ/</link>
		<comments>http://www.frederikvig.com/2010/02/adding-different-css-classes-when-using-the-episerver-pagetree/#comments</comments>
		<pubDate>Sat, 27 Feb 2010 23:26:49 +0000</pubDate>
		<dc:creator>Frederik Vig</dc:creator>
				<category><![CDATA[Code Snippet]]></category>
		<category><![CDATA[EPiServer]]></category>

		<guid isPermaLink="false">http://www.frederikvig.com/?p=1101</guid>
		<description><![CDATA[Another little quick tip. I was browsing the EPiServer World forum and came across a common question. 

by David Green
I am using the EpiServer:PageTree control to generate a nested &#60;ul&#62;&#60;li&#62; list in the format below.
However I am also using a dropdown menu system called UDM which requires that the class and id &#8220;udm&#8221; are on [...]]]></description>
			<content:encoded><![CDATA[<p>Another little quick tip. I was browsing the <a href="http://world.episerver.com/Forum/">EPiServer World forum</a> and came across a common <a href="http://world.episerver.com/Templates/Forum/Pages/Thread.aspx?id=37261&#038;epslanguage=en">question</a>. </p>
<blockquote><p>
<cite>by <a href="http://world.episerver.com/System/Users-and-profiles/Community-Profile-Card/?encryptedcurrentid=gH4Eg3C9NkmFoe0X/KzaZGdD9Rc1oiLE">David Green</a></cite></p>
<p>I am using the EpiServer:PageTree control to generate a nested &lt;ul&gt;&lt;li&gt; list in the format below.</p>
<p>However I am also using a dropdown menu system called UDM which requires that the class and id &#8220;udm&#8221; are on the first &lt;ul&gt; tag.</p>
</blockquote>
<p>The container object of the PageTree controller exposes the Indent property that we can use for this. Below is a simple example of how to add a CSS class to the first ul in your list (code is based on SubMenu.ascx from the EPiServer Public Templates package).</p>

<div class="wp_syntax"><div class="code"><pre class="csharp" style="font-family:monospace;"><span style="color: #008000;">&lt;%</span>@ Control Language<span style="color: #008000;">=</span><span style="color: #666666;">&quot;C#&quot;</span> EnableViewState<span style="color: #008000;">=</span><span style="color: #666666;">&quot;false&quot;</span> AutoEventWireup<span style="color: #008000;">=</span><span style="color: #666666;">&quot;False&quot;</span> CodeBehind<span style="color: #008000;">=</span><span style="color: #666666;">&quot;SubMenu.ascx.cs&quot;</span> Inherits<span style="color: #008000;">=</span><span style="color: #666666;">&quot;EPiServer.Templates.Public.Units.Static.SubMenu&quot;</span> <span style="color: #008000;">%&gt;</span>
<span style="color: #008000;">&lt;</span>EPiServer<span style="color: #008000;">:</span>PageTree ShowRootPage<span style="color: #008000;">=</span><span style="color: #666666;">&quot;false&quot;</span> runat<span style="color: #008000;">=</span><span style="color: #666666;">&quot;server&quot;</span> id<span style="color: #008000;">=</span><span style="color: #666666;">&quot;Menu&quot;</span><span style="color: #008000;">&gt;</span>
    <span style="color: #008000;">&lt;</span>IndentTemplate<span style="color: #008000;">&gt;</span>
        <span style="color: #008000;">&lt;</span>ul <span style="color: #008000;">&lt;%</span><span style="color: #008080;"># AddCssClassToFirstLevel(Container.Indent, &quot;udm&quot;) %&gt;&gt;</span>
    <span style="color: #008000;">&lt;/</span>IndentTemplate<span style="color: #008000;">&gt;</span>
    <span style="color: #008000;">&lt;</span>ItemHeaderTemplate<span style="color: #008000;">&gt;</span>
        <span style="color: #008000;">&lt;</span>li<span style="color: #008000;">&gt;</span>
    <span style="color: #008000;">&lt;/</span>ItemHeaderTemplate<span style="color: #008000;">&gt;</span>
    <span style="color: #008000;">&lt;</span>ItemTemplate<span style="color: #008000;">&gt;</span>
        <span style="color: #008000;">&lt;</span>EPiServer<span style="color: #008000;">:</span>Property PropertyName<span style="color: #008000;">=</span><span style="color: #666666;">&quot;PageLink&quot;</span> runat<span style="color: #008000;">=</span><span style="color: #666666;">&quot;server&quot;</span> <span style="color: #008000;">/&gt;</span>
    <span style="color: #008000;">&lt;/</span>ItemTemplate<span style="color: #008000;">&gt;</span>
    <span style="color: #008000;">&lt;</span>SelectedItemTemplate<span style="color: #008000;">&gt;</span>
	<span style="color: #008000;">&lt;</span>EPiServer<span style="color: #008000;">:</span>Property CssClass<span style="color: #008000;">=</span><span style="color: #666666;">&quot;selected&quot;</span> PropertyName<span style="color: #008000;">=</span><span style="color: #666666;">&quot;PageName&quot;</span> runat<span style="color: #008000;">=</span><span style="color: #666666;">&quot;server&quot;</span> <span style="color: #008000;">/&gt;</span>
    <span style="color: #008000;">&lt;/</span>SelectedItemTemplate<span style="color: #008000;">&gt;</span>
    <span style="color: #008000;">&lt;</span>ItemFooterTemplate<span style="color: #008000;">&gt;</span>
        <span style="color: #008000;">&lt;/</span>li<span style="color: #008000;">&gt;</span>
    <span style="color: #008000;">&lt;/</span>ItemFooterTemplate<span style="color: #008000;">&gt;</span>
    <span style="color: #008000;">&lt;</span>UnindentTemplate<span style="color: #008000;">&gt;</span>
        <span style="color: #008000;">&lt;/</span>ul<span style="color: #008000;">&gt;</span>
    <span style="color: #008000;">&lt;/</span>UnindentTemplate<span style="color: #008000;">&gt;</span>
<span style="color: #008000;">&lt;/</span>EPiServer<span style="color: #008000;">:</span>PageTree<span style="color: #008000;">&gt;</span></pre></div></div>


<div class="wp_syntax"><div class="code"><pre class="csharp" style="font-family:monospace;"><span style="color: #0600FF;">using</span> <span style="color: #008080;">System</span><span style="color: #008000;">;</span>
<span style="color: #0600FF;">using</span> <span style="color: #008080;">EPiServer</span><span style="color: #008000;">;</span>
<span style="color: #0600FF;">using</span> <span style="color: #008080;">EPiServer.Web.WebControls</span><span style="color: #008000;">;</span>
&nbsp;
<span style="color: #0600FF;">namespace</span> EPiServer.<span style="color: #0000FF;">Templates</span>.<span style="color: #0600FF;">Public</span>.<span style="color: #0000FF;">Units</span>.<span style="color: #0600FF;">Static</span>
<span style="color: #000000;">&#123;</span>
    <span style="color: #0600FF;">public</span> <span style="color: #0600FF;">partial</span> <span style="color: #FF0000;">class</span> SubMenu <span style="color: #008000;">:</span> UserControlBase
    <span style="color: #000000;">&#123;</span>
        <span style="color: #0600FF;">private</span> MenuList _menuList<span style="color: #008000;">;</span>
&nbsp;
        <span style="color: #008080; font-style: italic;">/// &lt;summary&gt;</span>
        <span style="color: #008080; font-style: italic;">/// Gets or sets the data source for this control</span>
        <span style="color: #008080; font-style: italic;">/// &lt;/summary&gt;</span>
        <span style="color: #0600FF;">public</span> MenuList MenuList
        <span style="color: #000000;">&#123;</span>
            get <span style="color: #000000;">&#123;</span> <span style="color: #0600FF;">return</span> _menuList<span style="color: #008000;">;</span> <span style="color: #000000;">&#125;</span>
            set <span style="color: #000000;">&#123;</span> _menuList <span style="color: #008000;">=</span> value<span style="color: #008000;">;</span> <span style="color: #000000;">&#125;</span>
        <span style="color: #000000;">&#125;</span>
&nbsp;
        <span style="color: #0600FF;">protected</span> <span style="color: #0600FF;">override</span> <span style="color: #0600FF;">void</span> OnLoad<span style="color: #000000;">&#40;</span><span style="color: #000000;">System</span>.<span style="color: #0000FF;">EventArgs</span> e<span style="color: #000000;">&#41;</span>
        <span style="color: #000000;">&#123;</span>
            <span style="color: #0600FF;">base</span>.<span style="color: #0000FF;">OnLoad</span><span style="color: #000000;">&#40;</span>e<span style="color: #000000;">&#41;</span><span style="color: #008000;">;</span>
&nbsp;
            <span style="color: #0600FF;">if</span> <span style="color: #000000;">&#40;</span>MenuList <span style="color: #008000;">==</span> <span style="color: #0600FF;">null</span><span style="color: #000000;">&#41;</span>
            <span style="color: #000000;">&#123;</span>
                return<span style="color: #008000;">;</span>
            <span style="color: #000000;">&#125;</span>
            Menu.<span style="color: #0000FF;">PageLink</span> <span style="color: #008000;">=</span> MenuList.<span style="color: #0000FF;">OpenTopPage</span><span style="color: #008000;">;</span>
            Menu.<span style="color: #0000FF;">DataBind</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #008000;">;</span>
        <span style="color: #000000;">&#125;</span>
&nbsp;
        <span style="color: #0600FF;">protected</span> <span style="color: #FF0000;">string</span> AddCssClassToFirstLevel<span style="color: #000000;">&#40;</span><span style="color: #FF0000;">int</span> level, <span style="color: #FF0000;">string</span> cssClassName<span style="color: #000000;">&#41;</span>
        <span style="color: #000000;">&#123;</span>
            <span style="color: #0600FF;">if</span> <span style="color: #000000;">&#40;</span>level <span style="color: #008000;">==</span> <span style="color: #FF0000;">1</span><span style="color: #000000;">&#41;</span>
            <span style="color: #000000;">&#123;</span>
                <span style="color: #0600FF;">return</span> <span style="color: #FF0000;">string</span>.<span style="color: #0000FF;">Format</span><span style="color: #000000;">&#40;</span><span style="color: #666666;">&quot;class=<span style="color: #008080; font-weight: bold;">\&quot;</span>{0}<span style="color: #008080; font-weight: bold;">\&quot;</span>&quot;</span>, cssClassName<span style="color: #000000;">&#41;</span><span style="color: #008000;">;</span>
            <span style="color: #000000;">&#125;</span>
&nbsp;
            <span style="color: #0600FF;">return</span> <span style="color: #FF0000;">string</span>.<span style="color: #0000FF;">Empty</span><span style="color: #008000;">;</span>
        <span style="color: #000000;">&#125;</span>
    <span style="color: #000000;">&#125;</span>
<span style="color: #000000;">&#125;</span></pre></div></div>

<p>We can easily add more complex logic. We also have access to the HasChildren property, which tells us if the active page has any children.</p>
<p>Hope this helps.<strong>Related Posts:</strong>
<ul class="similar-posts">
<li><a href="http://www.frederikvig.com/2009/08/episerver-web-controls-menulist-and-pagetree/" rel="bookmark" title="August 16, 2009">EPiServer web controls: MenuList and PageTree</a></li>
<li><a href="http://www.frederikvig.com/2009/12/part-4-creating-the-standard-page-create-an-episerver-site-from-scratch/" rel="bookmark" title="December 13, 2009">Part 4: Creating the standard page – Create an EPiServer site from scratch</a></li>
<li><a href="http://www.frederikvig.com/2009/11/the-selectedtemplate-and-duplicate-code/" rel="bookmark" title="November 11, 2009">The SelectedTemplate and duplicate code</a></li>
<li><a href="http://www.frederikvig.com/2009/07/episerver-web-controls-property/" rel="bookmark" title="July 5, 2009">EPiServer web controls: Property</a></li>
<li><a href="http://www.frederikvig.com/2009/10/creating-an-episerver-plugin/" rel="bookmark" title="October 8, 2009">Creating an EPiServer Plugin</a></li>
</ul>
<p><!-- Similar Posts took 12.924 ms --></p>
<img src="http://feeds.feedburner.com/~r/frederikvig/~4/LQlRQfOogeQ" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.frederikvig.com/2010/02/adding-different-css-classes-when-using-the-episerver-pagetree/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		<feedburner:origLink>http://www.frederikvig.com/2010/02/adding-different-css-classes-when-using-the-episerver-pagetree/</feedburner:origLink></item>
		<item>
		<title>Getting the Page and EPiServer CurrentPage object from HttpContext</title>
		<link>http://feedproxy.google.com/~r/frederikvig/~3/Vw2ZjuXALSI/</link>
		<comments>http://www.frederikvig.com/2010/02/getting-the-page-and-episerver-currentpage-object-from-httpcontext/#comments</comments>
		<pubDate>Sat, 20 Feb 2010 10:25:37 +0000</pubDate>
		<dc:creator>Frederik Vig</dc:creator>
				<category><![CDATA[ASP.NET]]></category>
		<category><![CDATA[EPiServer]]></category>

		<guid isPermaLink="false">http://www.frederikvig.com/?p=1092</guid>
		<description><![CDATA[Just a little quick tip when needing to use either the Page object or the EPiServer CurrentPage object from a class file. HttpContext.Current will give you access to the current request, what we can do is cast HttpContext.Current.Handler (since Page implements the IHttpHandler interface) to System.Web.UI.Page.

var page = HttpContext.Current.Handler as System.Web.UI.Page;
&#160;
if &#40;page != null&#41;
&#123;
  [...]]]></description>
			<content:encoded><![CDATA[<p>Just a little quick tip when needing to use either the Page object or the EPiServer CurrentPage object from a class file. HttpContext.Current will give you access to the current request, what we can do is cast HttpContext.Current.Handler (since Page implements the IHttpHandler interface) to System.Web.UI.Page.</p>

<div class="wp_syntax"><div class="code"><pre class="csharp" style="font-family:monospace;">var page <span style="color: #008000;">=</span> HttpContext.<span style="color: #0000FF;">Current</span>.<span style="color: #0000FF;">Handler</span> <span style="color: #0600FF;">as</span> <span style="color: #000000;">System.<span style="color: #0000FF;">Web</span>.<span style="color: #0000FF;">UI</span></span>.<span style="color: #0000FF;">Page</span><span style="color: #008000;">;</span>
&nbsp;
<span style="color: #0600FF;">if</span> <span style="color: #000000;">&#40;</span>page <span style="color: #008000;">!=</span> <span style="color: #0600FF;">null</span><span style="color: #000000;">&#41;</span>
<span style="color: #000000;">&#123;</span>
    <span style="color: #008080; font-style: italic;">// do something with the page object</span>
<span style="color: #000000;">&#125;</span></pre></div></div>

<p>We can take this a step further and cast it to EPiServer.PageBase which gives us access to the CurrentPage object.</p>

<div class="wp_syntax"><div class="code"><pre class="csharp" style="font-family:monospace;"><span style="color: #0600FF;">private</span> <span style="color: #0600FF;">static</span> PageData CurrentPage
<span style="color: #000000;">&#123;</span>
    get
    <span style="color: #000000;">&#123;</span>
	var page <span style="color: #008000;">=</span> HttpContext.<span style="color: #0000FF;">Current</span>.<span style="color: #0000FF;">Handler</span> <span style="color: #0600FF;">as</span> EPiServer.<span style="color: #0000FF;">PageBase</span><span style="color: #008000;">;</span>
&nbsp;
	<span style="color: #0600FF;">if</span> <span style="color: #000000;">&#40;</span>page <span style="color: #008000;">==</span> <span style="color: #0600FF;">null</span><span style="color: #000000;">&#41;</span>
	<span style="color: #000000;">&#123;</span>
	    <span style="color: #0600FF;">return</span> null<span style="color: #008000;">;</span>
	<span style="color: #000000;">&#125;</span>
&nbsp;
	<span style="color: #0600FF;">return</span> page.<span style="color: #0000FF;">CurrentPage</span><span style="color: #008000;">;</span>
    <span style="color: #000000;">&#125;</span>
<span style="color: #000000;">&#125;</span></pre></div></div>

<p><strong>Related Posts:</strong>
<ul class="similar-posts">
<li><a href="http://www.frederikvig.com/2009/10/sending-confirmation-email-to-the-user-when-using-episerver-xforms/" rel="bookmark" title="October 17, 2009">Sending confirmation email to the user when using EPiServer XForms</a></li>
<li><a href="http://www.frederikvig.com/2009/12/extending-pagedata-with-some-cool-html-helpers/" rel="bookmark" title="December 8, 2009">Extending PageData with some cool Html Helpers</a></li>
<li><a href="http://www.frederikvig.com/2009/05/episerver-extension-methods/" rel="bookmark" title="May 4, 2009">EPiServer Extension Methods</a></li>
<li><a href="http://www.frederikvig.com/2009/09/creating-a-custom-episerver-paging-control/" rel="bookmark" title="September 20, 2009">Creating a Custom EPiServer Paging Control</a></li>
<li><a href="http://www.frederikvig.com/2009/05/cast-from-bool-to-bool/" rel="bookmark" title="May 4, 2009">Safely Cast from bool? to bool</a></li>
</ul>
<p><!-- Similar Posts took 9.558 ms --></p>
<img src="http://feeds.feedburner.com/~r/frederikvig/~4/Vw2ZjuXALSI" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.frederikvig.com/2010/02/getting-the-page-and-episerver-currentpage-object-from-httpcontext/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://www.frederikvig.com/2010/02/getting-the-page-and-episerver-currentpage-object-from-httpcontext/</feedburner:origLink></item>
		<item>
		<title>Visual Studio 2010 EPiServer Snippets</title>
		<link>http://feedproxy.google.com/~r/frederikvig/~3/tJqP2psMy-4/</link>
		<comments>http://www.frederikvig.com/2010/02/visual-studio-2010-episerver-snippets/#comments</comments>
		<pubDate>Thu, 11 Feb 2010 16:38:06 +0000</pubDate>
		<dc:creator>Frederik Vig</dc:creator>
				<category><![CDATA[ASP.NET]]></category>
		<category><![CDATA[EPiServer]]></category>
		<category><![CDATA[Visual Studio]]></category>

		<guid isPermaLink="false">http://www.frederikvig.com/?p=1079</guid>
		<description><![CDATA[I finally got my hands on a copy of Visual Studio 2010 RC1! After playing around a bit, I stumbled across the new snippet functionality in Visual Studio 2010. You can now use snippets in the markup files as well (in previous versions you could only use the snippet functionality in code files like class/interfaces/code-behind [...]]]></description>
			<content:encoded><![CDATA[<p>I finally got my hands on a copy of Visual Studio 2010 RC1! After playing around a bit, I stumbled across the new snippet functionality in Visual Studio 2010. You can now use snippets in the markup files as well (in previous versions you could only use the snippet functionality in code files like class/interfaces/code-behind files etc). This is very cool, and Microsoft has even included a few snippets for their ASP.NET controls and for HTML elements like: a, table, img, div etc. Quite a time saver! </p>
<p>To test the snippets out, simply type the shortcut (eg. &#8216;a&#8217; or &#8216;table&#8217;) and press tab. </p>
<p><img src="http://www.frederikvig.com/wp-content/uploads/VS2010/table.png" alt="Visual Studio 2010 table snippet" /></p>
<p><img src="http://www.frederikvig.com/wp-content/uploads/VS2010/table-after-tab.png" alt="Visual Studio 2010 table snippet" /></p>
<p>This is a simple, but very cool feature. Imaging all the typing you can get rid off! </p>
<h3>Creating your own snippets</h3>
<p>In Visual Studio 2010, under the Tools menu, you&#8217;ll find the Code Snippets Manager (ctrl+k, ctrl+b).  </p>
<p><img src="http://www.frederikvig.com/wp-content/uploads/VS2010/snippets-manager.png" alt="Visual Studio 2010 Code Snippets Manager" /></p>
<p>Here you can add new folders that contain your custom snippets, or check out the other snippets added by Microsoft. You&#8217;ll also see the path to the snippets folder (C:\Program Files (x86)\Microsoft Visual Studio 10.0\Web\Snippets\HTML\1033\ in my case). If you open up that folder in Windows Explorer you should see at least two folders there, ASP.NET and HTML. Inside both of these folders you&#8217;ll find the snippets for the ASP.NET web controls and for HTML elements. We can open up one of the files and take a look at the code.</p>

<div class="wp_syntax"><div class="code"><pre class="xml" style="font-family:monospace;"><span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;CodeSnippet</span> <span style="color: #000066;">Format</span>=<span style="color: #ff0000;">&quot;1.1.0&quot;</span> <span style="color: #000066;">xmlns</span>=<span style="color: #ff0000;">&quot;http://schemas.microsoft.com/VisualStudio/2005/CodeSnippet&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>
  <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;Header<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;Title<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>image<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/Title<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;Author<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>Microsoft Corporation<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/Author<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;Shortcut<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>image<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/Shortcut<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;AlternativeShortcuts<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
      <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;Shortcut<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>imagebutton<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/Shortcut<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
      <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;Shortcut</span> <span style="color: #000066;">Value</span>=<span style="color: #ff0000;">&quot;image&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>asp:image<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/Shortcut<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
      <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;Shortcut</span> <span style="color: #000066;">Value</span>=<span style="color: #ff0000;">&quot;imagebutton&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>asp:imagebutton<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/Shortcut<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/AlternativeShortcuts<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;Description<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>Markup snippet for a control that contains an image<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/Description<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;SnippetTypes<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
      <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;SnippetType<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>Expansion<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/SnippetType<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/SnippetTypes<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
  <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/Header<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
  <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;Snippet<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;Declarations<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
      <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;Literal<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
        <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;ID<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>imageurl<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/ID<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
        <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;ToolTip<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>imageurl<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/ToolTip<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
        <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;Default<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>imageurl<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/Default<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
      <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/Literal<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/Declarations<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;Code</span> <span style="color: #000066;">Language</span>=<span style="color: #ff0000;">&quot;html&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span><span style="color: #339933;">&lt;![CDATA[&lt;asp:$shortcut$ imageurl=&quot;$imageurl$&quot; runat=&quot;server&quot; /&gt;$end$]]&gt;</span><span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/Code<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
  <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/Snippet<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/CodeSnippet<span style="color: #000000; font-weight: bold;">&gt;</span></span></span></pre></div></div>

<p>Very easy and readable XML markup, that we easily can tweak to our needs. Say we&#8217;re working on a project where 90% of the tables we create should have a class of &#8220;products&#8221;. Lets create a snippet for this, so that we don&#8217;t have to type the same thing every time. </p>
<p>Create a new snippet called table-products.snippet, open it up in your favorite code editor and add this code.</p>

<div class="wp_syntax"><div class="code"><pre class="xml" style="font-family:monospace;"><span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;CodeSnippet</span> <span style="color: #000066;">Format</span>=<span style="color: #ff0000;">&quot;1.1.0&quot;</span> <span style="color: #000066;">xmlns</span>=<span style="color: #ff0000;">&quot;http://schemas.microsoft.com/VisualStudio/2005/CodeSnippet&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>
  <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;Header<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;Title<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>table<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/Title<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;Author<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>Frederik Vig<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/Author<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;Shortcut<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>tablep<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/Shortcut<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;Description<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>Markup snippet for a table with class products<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/Description<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;SnippetTypes<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
      <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;SnippetType<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>Expansion<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/SnippetType<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
      <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;SnippetType<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>SurroundsWith<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/SnippetType<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/SnippetTypes<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
  <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/Header<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
  <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;Snippet<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;Declarations<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
      <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;Literal<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
        <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;ID<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>cellspacing<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/ID<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
        <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;ToolTip<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>cellspacing<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/ToolTip<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
        <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;Default<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>0<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/Default<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
      <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/Literal<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/Declarations<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;Code</span> <span style="color: #000066;">Language</span>=<span style="color: #ff0000;">&quot;html&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span><span style="color: #339933;">&lt;![CDATA[&lt;table cellspacing=&quot;$cellspacing$&quot; class=&quot;products&quot;&gt;</span>
<span style="color: #339933;">    &lt;tr&gt;</span>
<span style="color: #339933;">        &lt;td&gt;$selected$$end$&lt;/td&gt;</span>
<span style="color: #339933;">    &lt;/tr&gt;</span>
<span style="color: #339933;">&lt;/table&gt;]]&gt;</span><span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/Code<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
  <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/Snippet<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/CodeSnippet<span style="color: #000000; font-weight: bold;">&gt;</span></span></span></pre></div></div>

<p>I&#8217;ve saved table-products.snippet directly in the HTML snippet folder (C:\Program Files (x86)\Microsoft Visual Studio 10.0\Web\Snippets\HTML\1033\HTML in my case), but you can save it anywhere, just remember to add the snippet folder with the Code Snippets Manager in Visual Studio. </p>
<p>We can now test the snippet by typing tablep and pressing tab.</p>
<p><img src="http://www.frederikvig.com/wp-content/uploads/VS2010/tablep.png" alt="Visual Studio 2010 table products snippet" /></p>
<p>
<img src="http://www.frederikvig.com/wp-content/uploads/VS2010/tablep-after-tab.png" alt="Visual Studio 2010 table products snippet" />
</p>
<p>Simple example, I know, but you get the idea!.</p>
<h3>EPiServer</h3>
<p>Naturally, one of the first things I did was add the <a href="http://www.frederikvig.com/2009/07/episerver-web-controls-property/">EPiServer Property web control</a> to the snippet manager <img src='http://www.frederikvig.com/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' /> . This turned out to be very easy! So I continued on adding snippets for the other EPiServer web controls as well. Here is the list of snippets with their shortcut.</p>
<ul>
<li><a href="http://sdk.episerver.com/library/cms5/html/T_EPiServer_Web_WebControls_Calendar.htm">EPiServer Calendar</a> &#8211; shortcut: ec</li>
<li><a href="http://sdk.episerver.com/library/cms5/html/T_EPiServer_Web_WebControls_CategoryDataSource.htm">EPiServer CategoryDataSource</a> &#8211; shortcut: ecd</li>
<li><a href="http://sdk.episerver.com/library/cms5/html/T_EPiServer_Web_WebControls_FileSystemDataSource.htm">EPiServer FileSystemDataSource</a> &#8211; shortcut: efsd</li>
<li><a href="http://sdk.episerver.com/library/cms5/html/T_EPiServer_Web_WebControls_LanguageDataSource.htm">EPiServer LanguageDataSource</a> &#8211; shortcut: eld</li>
<li><a href="http://sdk.episerver.com/library/cms5/html/T_EPiServer_Web_WebControls_MembershipUserDataSource.htm">EPiServer MembershipUserDataSource</a> &#8211; shortcut: emud</li>
<li><a href="http://sdk.episerver.com/library/cms5/html/T_EPiServer_Web_WebControls_MenuList.htm">EPiServer MenuList</a> &#8211; shortcut: eml</li>
<li><a href="http://sdk.episerver.com/library/cms5/html/T_EPiServer_Web_WebControls_NewsList.htm">EPiServer NewsList</a> &#8211; shortcut: enl</li>
<li><a href="http://sdk.episerver.com/library/cms5/html/T_EPiServer_Web_WebControls_OnPageEditControl.htm">EPiServer OnPageEditControl</a> &#8211; shortcut: eopec</li>
<li><a href="http://sdk.episerver.com/library/cms5/html/T_EPiServer_Web_WebControls_PageDataSource.htm">EPiServer PageDataSource</a> &#8211; shortcut: epd</li>
<li><a href="http://sdk.episerver.com/library/cms5/html/T_EPiServer_Web_WebControls_PageDefinitionDataSource.htm">EPiServer PageDefinitionDataSource</a> &#8211; shortcut: epdd</li>
<li><a href="http://sdk.episerver.com/library/cms5/html/T_EPiServer_Web_WebControls_PageDefinitionTypeDataSource.htm">EPiServer PageDefinitionTypeDataSource</a> &#8211; shortcut: epdtd</li>
<li><a href="http://sdk.episerver.com/library/cms5/html/T_EPiServer_Web_WebControls_PageList.htm">EPiServer PageList</a> &#8211; shortcut: epl</li>
<li><a href="http://sdk.episerver.com/library/cms5/html/T_EPiServer_Web_WebControls_PageListData.htm">EPiServer PageListData</a> &#8211; shortcut: epld</li>
<li><a href="http://sdk.episerver.com/library/cms5/html/T_EPiServer_Web_WebControls_PageTree.htm">EPiServer PageTree</a> &#8211; shortcut: ept</li>
<li><a href="http://sdk.episerver.com/library/cms5/html/T_EPiServer_Web_WebControls_PageTreeData.htm">EPiServer PageTreeData</a> &#8211; shortcut: eptd</li>
<li><a href="http://sdk.episerver.com/library/cms5/html/T_EPiServer_Web_WebControls_PageVersionDataSource.htm">EPiServer PageVersionDataSource</a> &#8211; shortcut: epvd</li>
<li><a href="http://sdk.episerver.com/library/cms5/html/T_EPiServer_Web_WebControls_Property.htm">EPiServer Property</a> &#8211; shortcut: ep</li>
<li><a href="http://sdk.episerver.com/library/cms5/html/T_EPiServer_Web_WebControls_PropertyCriteriaControl.htm">EPiServer PropertyCriteriaControl</a> &#8211; shortcut: epcc</li>
<li><a href="http://sdk.episerver.com/library/cms5/html/T_EPiServer_Web_WebControls_SearchDataSource.htm">EPiServer SearchDataSource</a> &#8211; shortcut: esd</li>
<li><a href="http://sdk.episerver.com/library/cms5/html/T_EPiServer_Web_WebControls_SoftLinkDataSource.htm">EPiServer SoftLinkDataSource</a> &#8211; shortcut: esld</li>
<li><a href="http://sdk.episerver.com/library/cms5/html/T_EPiServer_Web_WebControls_SubscriptionDataSource.htm">EPiServer SubscriptionDataSource</a> &#8211; shortcut: esds</li>
<li><a href="http://sdk.episerver.com/library/cms5/html/T_EPiServer_Web_WebControls_TabDefinitionDataSource.htm">EPiServer TabDefinitionDataSource</a> &#8211; shortcut: etdd</li>
<li><a href="http://sdk.episerver.com/library/cms5/html/T_EPiServer_Web_WebControls_ThemeImage.htm">EPiServer ThemeImage</a> &#8211; shortcut: eti</li>
<li><a href="http://sdk.episerver.com/library/cms5/html/T_EPiServer_Web_WebControls_Translate.htm">EPiServer Translate</a> &#8211; shortcut: et</li>
</ul>
<p><a href="http://www.frederikvig.com/wp-content/uploads/VS2010/EPiServer-VS2010-Snippets.zip">Download the snippets</a></p>
<p><strong>Related Posts:</strong>
<ul class="similar-posts">
<li><a href="http://www.frederikvig.com/2009/12/part-1-setting-up-the-development-environment-create-an-episerver-site-from-scratch/" rel="bookmark" title="December 4, 2009">Part 1: Setting up the development environment &#8211; Create an EPiServer site from scratch</a></li>
<li><a href="http://www.frederikvig.com/2010/01/episerver-code-walkthrough-1-404-handler/" rel="bookmark" title="January 29, 2010">EPiServer code walkthrough #1 &#8211; 404 handler</a></li>
<li><a href="http://www.frederikvig.com/2009/12/part-2-creating-a-foundation-create-an-episerver-site-from-scratch/" rel="bookmark" title="December 7, 2009">Part 2: Creating a foundation &#8211; Create an EPiServer site from scratch</a></li>
<li><a href="http://www.frederikvig.com/2009/12/part-3-creating-the-start-page-create-an-episerver-site-from-scratch/" rel="bookmark" title="December 10, 2009">Part 3: Creating the start page – Create an EPiServer site from scratch</a></li>
<li><a href="http://www.frederikvig.com/2009/12/part-8-preparing-for-launch-create-an-episerver-site-from-scratch/" rel="bookmark" title="December 24, 2009">Part 8: Preparing for launch – Create an EPiServer site from scratch</a></li>
</ul>
<p><!-- Similar Posts took 18.912 ms --></p>
<img src="http://feeds.feedburner.com/~r/frederikvig/~4/tJqP2psMy-4" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.frederikvig.com/2010/02/visual-studio-2010-episerver-snippets/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://www.frederikvig.com/2010/02/visual-studio-2010-episerver-snippets/</feedburner:origLink></item>
		<item>
		<title>Guide to font sizing with CSS</title>
		<link>http://feedproxy.google.com/~r/frederikvig/~3/tvy8zSSzKxA/</link>
		<comments>http://www.frederikvig.com/2010/02/guide-to-font-sizing-with-css/#comments</comments>
		<pubDate>Sat, 06 Feb 2010 09:23:55 +0000</pubDate>
		<dc:creator>Frederik Vig</dc:creator>
				<category><![CDATA[CSS]]></category>
		<category><![CDATA[Web design]]></category>

		<guid isPermaLink="false">http://www.frederikvig.com/?p=1057</guid>
		<description><![CDATA[Font sizing with CSS and browser support as always been a mystery to me. We used to use pixels, than we switched to ems and percent, then we switched back to pixels again?!.. In this post I&#8217;ve tried shedding some light on the matter and explaining the reason for this, and the different ways of [...]]]></description>
			<content:encoded><![CDATA[<p>Font sizing with CSS and browser support as always been a mystery to me. We used to use pixels, than we switched to ems and percent, then we switched back to pixels again?!.. In this post I&#8217;ve tried shedding some light on the matter and explaining the reason for this, and the different ways of doing font sizing on the web. </p>
<p>You have quite a few different measuring units to use in CSS for use with the font-size property (em, ex, px, in, cm, mm, pt, pc, %). We can group these lengths into two groups.</p>
<h3>Relative lenghts</h3>
<ul>
<li>em: the &#8216;font-size&#8217; of the relevant font</li>
<li>ex: the &#8216;x-height&#8217; of the relevant font</li>
<li>px: pixels, relative to the viewing device (resolution and pixel density)</li>
</ul>
<h3>Absolute lengths</h3>
<ul>
<li>in: inches — 1 inch is equal to 2.54 centimeters.</li>
<li>cm: centimeters</li>
<li>mm: millimeters</li>
<li>pt: points — the points used by CSS 2.1 are equal to 1/72nd of an inch.</li>
<li>pc: picas — 1 pica is equal to 12 points.</li>
</ul>
<p>Percentage values are always relative to a length or other value.</p>
<p>To be honest I only use four of these units. I use points (pt) in my print stylesheet, and px, em and % for my screen stylesheet. </p>
<h3>Pixels</h3>
<p>When using pixels for your font size you don&#8217;t have much to think about, 12px is 12px in every browser. What can be a problem, and what is the main reason that organizations like the <a href="http://www.w3.org">W3C</a> advice against using pixels for font size measurement, is the lack of support in browsers like Internet Explorer 6 when changing the browser&#8217;s default font size. The reason for this is that most browsers used to use text scaling for this, only enlarging the text on the page. However the newest versions of all the major browsers now use page zooming instead. What this does is increase (or decrease) all the elements on the page, not just the text, by zooming. </p>
<p>Lack of support for page zooming in Internet Explorer 6 can be a problem. If it is you should consider using ems and percent, which all browsers support. You can use ems/percent either for all browsers or by using a conditional comment stylesheet for Internet Explorer 6 and using pixels for the rest. I personally have started using pixels again, simple because it saves me a ton of work, and is much more reliable for measurement than using % and ems.</p>
<h3>Ems and percent</h3>
<p>If your audience still consists of a lot of Internet Explorer 6 users, you might want to stick with using ems or % for measurement. The rule to follow here is <strong>target &divide; context = result</strong>.</p>
<h4>Example</h4>
<p>If we give body a font size of 100% (roughly around 16px in most browsers), we can use that as the context. So if we want 12px in font size for normal text, and 20px for headings, this then becomes the target.</p>
<ul>
<li>12 &divide; 16 = 0,75</li>
<li>20 &divide; 16 = 1,25</li>
</ul>

<div class="wp_syntax"><div class="code"><pre class="css" style="font-family:monospace;">body <span style="color: #00AA00;">&#123;</span>
    <span style="color: #000000; font-weight: bold;">font-size</span><span style="color: #00AA00;">:</span> <span style="color: #933;"><span style="color: #cc66cc;">100</span>%</span><span style="color: #00AA00;">;</span>
<span style="color: #00AA00;">&#125;</span>
p <span style="color: #00AA00;">&#123;</span>
    <span style="color: #000000; font-weight: bold;">font-size</span><span style="color: #00AA00;">:</span> <span style="color: #933;">.75em</span><span style="color: #00AA00;">;</span>
<span style="color: #00AA00;">&#125;</span>
&nbsp;
h1 <span style="color: #00AA00;">&#123;</span>
    <span style="color: #000000; font-weight: bold;">font-size</span><span style="color: #00AA00;">:</span> <span style="color: #933;">1.25em</span><span style="color: #00AA00;">;</span>
<span style="color: #00AA00;">&#125;</span></pre></div></div>

<p>If we&#8217;d used pixels we would have something like this.</p>

<div class="wp_syntax"><div class="code"><pre class="css" style="font-family:monospace;">p <span style="color: #00AA00;">&#123;</span>
    <span style="color: #000000; font-weight: bold;">font-size</span><span style="color: #00AA00;">:</span> <span style="color: #933;">12px</span><span style="color: #00AA00;">;</span>
<span style="color: #00AA00;">&#125;</span>
&nbsp;
h1 <span style="color: #00AA00;">&#123;</span>
    <span style="color: #000000; font-weight: bold;">font-size</span><span style="color: #00AA00;">:</span> <span style="color: #933;">20px</span><span style="color: #00AA00;">;</span>
<span style="color: #00AA00;">&#125;</span></pre></div></div>

<p>Okay, say we have some text inside our paragraphs that we want to be 13px. The target becomes 13px, but the context changes, instead of using the body as the context, the paragraph becomes the context. So we get 13 &divide; 12 = 1,0833.</p>

<div class="wp_syntax"><div class="code"><pre class="css" style="font-family:monospace;">p strong <span style="color: #00AA00;">&#123;</span>
    <span style="color: #000000; font-weight: bold;">font-size</span><span style="color: #00AA00;">:</span> <span style="color: #933;">1.0833em</span><span style="color: #00AA00;">;</span>
<span style="color: #00AA00;">&#125;</span></pre></div></div>

<p>By using the <strong>target &divide; context = result</strong> rule, everything comes down to maths <img src='http://www.frederikvig.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> .</p>
<p>Here is the live example with <a href="http://www.frederikvig.com/wp-content/uploads/font-sizing/font-sizing.html">ems and percent</a> and here with <a href="http://www.frederikvig.com/wp-content/uploads/font-sizing/font-sizing-px.html">pixels</a>.</p>
<p>So, what are you using?<strong>Related Posts:</strong>
<ul class="similar-posts">
<li><a href="http://www.frederikvig.com/2009/10/font-resizing-and-printing-with-jquery/" rel="bookmark" title="October 27, 2009">Font resizing and printing with jQuery</a></li>
<li><a href="http://www.frederikvig.com/2009/05/css-tricks-part-1/" rel="bookmark" title="May 31, 2009">CSS tricks &#8211; part 1</a></li>
<li><a href="http://www.frederikvig.com/2009/05/transparent-pngs/" rel="bookmark" title="May 5, 2009">Transparent PNGs</a></li>
<li><a href="http://www.frederikvig.com/2009/07/asp-net-web-forms-and-jquery-thickbox-plugin/" rel="bookmark" title="July 13, 2009">ASP.NET web forms and jQuery Thickbox plugin</a></li>
<li><a href="http://www.frederikvig.com/2009/08/adding-css-and-javascript-files-dynamically-to-your-asp-net-page/" rel="bookmark" title="August 15, 2009">Adding CSS and JavaScript files dynamically to your ASP.NET page</a></li>
</ul>
<p><!-- Similar Posts took 9.329 ms --></p>
<img src="http://feeds.feedburner.com/~r/frederikvig/~4/tvy8zSSzKxA" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.frederikvig.com/2010/02/guide-to-font-sizing-with-css/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		<feedburner:origLink>http://www.frederikvig.com/2010/02/guide-to-font-sizing-with-css/</feedburner:origLink></item>
		<item>
		<title>EPiServer code walkthrough #1 – 404 handler</title>
		<link>http://feedproxy.google.com/~r/frederikvig/~3/jZN1dHlYmbY/</link>
		<comments>http://www.frederikvig.com/2010/01/episerver-code-walkthrough-1-404-handler/#comments</comments>
		<pubDate>Fri, 29 Jan 2010 15:10:11 +0000</pubDate>
		<dc:creator>Frederik Vig</dc:creator>
				<category><![CDATA[ASP.NET]]></category>
		<category><![CDATA[C#]]></category>
		<category><![CDATA[EPiServer]]></category>
		<category><![CDATA[EPiServer code walkthrough]]></category>

		<guid isPermaLink="false">http://www.frederikvig.com/?p=1038</guid>
		<description><![CDATA[This is the first post in a new series called &#8220;EPiServer code walkthrough&#8221;. What I&#8217;ll do is go through one new EPiServer module in each post. Writing a little about what it does, learn by reading its code, and  hopefully contributing a little back to the project, if I see any bugs or harmful/unnecessary [...]]]></description>
			<content:encoded><![CDATA[<p>This is the first post in a new series called &#8220;EPiServer code walkthrough&#8221;. What I&#8217;ll do is go through one new EPiServer module in each post. Writing a little about what it does, learn by reading its code, and  hopefully contributing a little back to the project, if I see any bugs or harmful/unnecessary code that is <img src='http://www.frederikvig.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> . </p>
<p>I&#8217;m a firm believer that reading code helps you become a better developer. There are lots of modules even I just recently came across, that I didn&#8217;t know existed just a few weeks back. I think I&#8217;m not the only one, especially since they are spread around on various blogs, <a href="http://www.codeplex.com/">CodePlex</a>, <a href="https://www.coderesort.com/p/epicode/wiki/WikiStart">EPiCode</a> and other places. They all contain valuable code that we as EPiServer developers should read.</p>
<p>I&#8217;m starting with a module I personally have not used much before, but that I know a lot of people have used in their projects: the <a href="https://www.coderesort.com/p/epicode/wiki/404Handler">custom 404 handler</a>. </p>
<blockquote><p>
<cite>From the project wiki page</cite></p>
<p>This module has a more advanced url redirect feature than the built-in shortcut url feature in EPiServer. It handles extensions and querystring parameters too. If you have a lot of 404 errors in your logs, you can use this to redirect the user to the correct page. Especially useful if you move templates or pages around, or have just installed EPiServer and have a lot of old urls that is no longer available.</p>
</blockquote>
<p><a href="https://www.coderesort.com/p/epicode/wiki/404Handler">404 handlers wiki page</a> explains in detail what you need to do to install the module, so I&#8217;m not going to repeat it here. Instead we&#8217;ll take a look at the code. </p>
<p>Start by doing a SVN checkout of the source code (the svn url is https://www.coderesort.com/svn/epicode/BVNetwork.404Handler/5.x/).</p>
<p><img src="http://www.frederikvig.com/wp-content/uploads/EPiServer-code-walkthrough/404handler/checkout.png" alt="SVN checkout of 404 handler" /></p>
<p>When opening up the BVNetwork.404Handler folder you&#8217;ll see a readme.txt file explaining the purpose of the module, installation, configuration etc. This is something I like! Not everyone reads the wiki page, and we as developers are especially lazy when it comes to reading documentation. Having a readme.txt with everything you need makes this so much easier, and gives the module author less support questions to answer. When using a new module, always make sure to read the documentation before asking the author questions. Saves both parties time <img src='http://www.frederikvig.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> .</p>
<p>Lets open up BVNetwork.404Handler.csproj in Visual Studio.</p>
<p><img src="http://www.frederikvig.com/wp-content/uploads/EPiServer-code-walkthrough/404handler/visual-studio-project-structure.png" alt="404 handler project structure in Visual Studio" /></p>
<p>As you can see the project is structured pretty nice, with good separations between the different parts. Very good that the project uses languages files, and that they&#8217;ve included them for five different languages. Not all modules use the language files, and if they do, they seldom have any more than one update-to-date English language file. Kudos for this. </p>
<p>What I don&#8217;t like is the missing fnf_logo.gif image file in the Images folder. A quick search in Visual Studio shows that this file is no longer in use, and should therefore be removed from the project. A missing image file is not the end of the world, and I know people make mistakes/forget to commit all their files, but this can be very annoying and even lead to a lot of work for other developers using your code or taking over a project. </p>
<p>Always make sure that your project builds on other computers than your own. I recommend manually setting up the project on preferably a new computer to see that everything works as expected, you can also use the same computer, but make sure to do the normal process a new developer would use when setting up the project (new checkout etc). Especially on larger projects that have quite a few things to setup you should do this. You&#8217;ll also receive some valuable feedback if your setup process is to complex (again on larger projects this happens quite frequently). Another thing you should use is a <a href="http://en.wikipedia.org/wiki/Continuous_integration">build server</a>. There are <a href="http://www.jetbrains.com/teamcity/">quite</a> a <a href="http://cruisecontrol.sourceforge.net/">few</a> out there, I know CodeResort just added <a href="http://bitten.edgewall.org/">Bitten</a> as their build server for CodeResort projects. In a nutshell what a build server does is make sure you&#8217;ve included all the files and resources needed to build your project, run various tests (if you have any), deploy your files, create reports, notify team members if their build fails, and a bunch of other stuff, automatically for you. I&#8217;ll try to write a blog post up with more information on build and continuous integration servers.</p>
<p>Lets get back to the Visual Studio and the project! One of the things you should start out with is actually making sure the project builds after doing a checkout. So, either press ctrl + shift + b or go to Build -> Build BVNetwork.404Handler. You should have a successful build.</p>
<p>If we take a look through the code we see that most of the code is well documented and follows a nice naming convention making it easy to know what the purpose of the class is (CustomRedirectHandler.cs, CustomRedirectCollection.cs, Custom404Handler.cs etc). But we also see a few minor things we can clean up: unused using statements, commented out code, unused field variables etc. These are minor, but still important things to get rid of. Always strive for a clean code base, commented out code is something you should never commit into a repository, the whole reason for having a source control system is so that you can look at previous changesets and their code, there is no reason to keep the commented out code there, it will only be forgotten by the developer who commented out the code, and the other developers don&#8217;t know what to do with it, and will most likely just let it be. When I come across this I show no mercy and just delete it! </p>
<p>You&#8217;ll also see a few System.Diagnostics.Debug.WriteLine that are commented out. The project now uses Log4Net to log errors and warnings, System.Diagnostics.Debug.WriteLine is legacy code that we can safely remove. Another thing that I prefer is using string.Empty(); instead of &#8220;&#8221;, I&#8217;ve not updated the code because I feel this is more a personal preference. Same thing when it comes to over-documenting-code, like in this example.</p>

<div class="wp_syntax"><div class="code"><pre class="csharp" style="font-family:monospace;"><span style="color: #008080; font-style: italic;">/// &lt;summary&gt;</span>
<span style="color: #008080; font-style: italic;">/// The refering url</span>
<span style="color: #008080; font-style: italic;">/// &lt;/summary&gt;</span>
<span style="color: #0600FF;">public</span> <span style="color: #0600FF;">static</span> <span style="color: #FF0000;">string</span> GetReferer<span style="color: #000000;">&#40;</span><span style="color: #000000;">System.<span style="color: #0000FF;">Web</span>.<span style="color: #0000FF;">UI</span></span>.<span style="color: #0000FF;">Page</span> page<span style="color: #000000;">&#41;</span>
<span style="color: #000000;">&#123;</span>
    <span style="color: #FF0000;">string</span> referer <span style="color: #008000;">=</span> page.<span style="color: #0000FF;">Request</span>.<span style="color: #0000FF;">ServerVariables</span><span style="color: #000000;">&#91;</span><span style="color: #666666;">&quot;HTTP_REFERER&quot;</span><span style="color: #000000;">&#93;</span><span style="color: #008000;">;</span>
    <span style="color: #0600FF;">if</span> <span style="color: #000000;">&#40;</span>referer <span style="color: #008000;">!=</span> <span style="color: #0600FF;">null</span><span style="color: #000000;">&#41;</span>
    <span style="color: #000000;">&#123;</span>
	<span style="color: #008080; font-style: italic;">// Strip away host name in front, if local redirect</span>
	<span style="color: #FF0000;">string</span> hostUrl <span style="color: #008000;">=</span> EPiServer.<span style="color: #0000FF;">Configuration</span>.<span style="color: #0000FF;">Settings</span>.<span style="color: #0000FF;">Instance</span>.<span style="color: #0000FF;">SiteUrl</span>.<span style="color: #0000FF;">ToString</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #008000;">;</span>
	<span style="color: #0600FF;">if</span> <span style="color: #000000;">&#40;</span>referer.<span style="color: #0000FF;">StartsWith</span><span style="color: #000000;">&#40;</span>hostUrl<span style="color: #000000;">&#41;</span><span style="color: #000000;">&#41;</span>
	    referer <span style="color: #008000;">=</span> referer.<span style="color: #0000FF;">Remove</span><span style="color: #000000;">&#40;</span><span style="color: #FF0000;">0</span>, hostUrl.<span style="color: #0000FF;">Length</span><span style="color: #000000;">&#41;</span><span style="color: #008000;">;</span>
    <span style="color: #000000;">&#125;</span>
    <span style="color: #0600FF;">else</span>
	referer <span style="color: #008000;">=</span> <span style="color: #666666;">&quot;&quot;</span><span style="color: #008000;">;</span> <span style="color: #008080; font-style: italic;">// Can't have null</span>
    <span style="color: #0600FF;">return</span> referer<span style="color: #008000;">;</span>
<span style="color: #000000;">&#125;</span></pre></div></div>

<p>The document header can safely be removed since the method name does a good job at describing what the purpose of the method is. I&#8217;ve not removed the document header, since again this is my personal preference.</p>
<p>A thing I just noticed is that this is actually a Visual Studio class project, and not a Web Application project. I can only guess, but this is probably a project that got upgraded from Visual Studio 2003, I&#8217;ve previously had some problem upgrading a project from Visual Studio 2003 to Visual Studio 2008. The conversion usually goes okay (just an update to the csproj file mostly), but the ProjectTypeGuids doesn&#8217;t always get added. This is easy to fix, open up BVNetwork.404Handler.csproj in notepad or another source editor, and add this line.</p>

<div class="wp_syntax"><div class="code"><pre class="xml" style="font-family:monospace;"><span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;ProjectTypeGuids<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>{349c5851-65df-11da-9384-00065b846f21};{fae04ec0-301f-11d3-bf4b-00c04f79efbc}<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/ProjectTypeGuids<span style="color: #000000; font-weight: bold;">&gt;</span></span></span></pre></div></div>

<p>Save, and open up the project in Visual Studio. You should now see a slightly different icon at the top of the solution explorer window.</p>
<p><img src="http://www.frederikvig.com/wp-content/uploads/EPiServer-code-walkthrough/404handler/new-icon.png" alt="New project icon in Visual Studio" /></p>
<p>This will allow us to add a designer file to default.aspx from the admin folder. To do this simply right-click the file in solution explorer and choose &#8220;Convert to Web Application&#8221;. We can now delete the &#8220;Web Form Designer generated code&#8221;-region.</p>
<p>After all these updates its very important to make sure that the project still builds and that everything functions as expected by testing it.</p>
<p>What I liked the most with this project is how it uses logging. I&#8217;m personally very bad at using logging, and know that not all projects use logging as much as they should. Kudos to the authors for this!</p>
<p>I hope you&#8217;ve learned a few new things while reading this code, and be sure to try out the 404 handler! For SEO and user experience purposes it is crucial that the users have a smooth transition. They shouldn&#8217;t even notice the change when switching to EPiServer from another CMS (that uses different urls). A 404 (file not found) error message can also quickly become a major leak of traffic for your clients site.<strong>Related Posts:</strong>
<ul class="similar-posts">
<li><a href="http://www.frederikvig.com/2009/12/part-1-setting-up-the-development-environment-create-an-episerver-site-from-scratch/" rel="bookmark" title="December 4, 2009">Part 1: Setting up the development environment &#8211; Create an EPiServer site from scratch</a></li>
<li><a href="http://www.frederikvig.com/2010/02/visual-studio-2010-episerver-snippets/" rel="bookmark" title="February 11, 2010">Visual Studio 2010 EPiServer Snippets</a></li>
<li><a href="http://www.frederikvig.com/2010/01/2010/" rel="bookmark" title="January 9, 2010">2010</a></li>
<li><a href="http://www.frederikvig.com/2009/12/part-8-preparing-for-launch-create-an-episerver-site-from-scratch/" rel="bookmark" title="December 24, 2009">Part 8: Preparing for launch – Create an EPiServer site from scratch</a></li>
<li><a href="http://www.frederikvig.com/2009/12/part-2-creating-a-foundation-create-an-episerver-site-from-scratch/" rel="bookmark" title="December 7, 2009">Part 2: Creating a foundation &#8211; Create an EPiServer site from scratch</a></li>
</ul>
<p><!-- Similar Posts took 18.814 ms --></p>
<img src="http://feeds.feedburner.com/~r/frederikvig/~4/jZN1dHlYmbY" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.frederikvig.com/2010/01/episerver-code-walkthrough-1-404-handler/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		<feedburner:origLink>http://www.frederikvig.com/2010/01/episerver-code-walkthrough-1-404-handler/</feedburner:origLink></item>
		<item>
		<title>A developer’s guide to PageTypeBuilder</title>
		<link>http://feedproxy.google.com/~r/frederikvig/~3/ym7WramAUDw/</link>
		<comments>http://www.frederikvig.com/2010/01/a-developers-guide-to-pagetypebuilder/#comments</comments>
		<pubDate>Fri, 15 Jan 2010 13:43:30 +0000</pubDate>
		<dc:creator>Frederik Vig</dc:creator>
				<category><![CDATA[EPiServer]]></category>
		<category><![CDATA[PageTypeBuilder]]></category>

		<guid isPermaLink="false">http://www.frederikvig.com/?p=1015</guid>
		<description><![CDATA[
Page Type Builder allows developers to define EPiServer page types in code which eliminates the need to synchronize page types between different servers. As page types are declared in code it also enables inheritance between page types and strongly typed property access.
From the PageTypeBuilder project

Joel Abrahamsson has done a superb job with the project and [...]]]></description>
			<content:encoded><![CDATA[<blockquote>
<p>Page Type Builder allows developers to define EPiServer page types in code which eliminates the need to synchronize page types between different servers. As page types are declared in code it also enables inheritance between page types and strongly typed property access.</p>
<p><cite>From the <a href="http://pagetypebuilder.codeplex.com/">PageTypeBuilder project</a></cite>
</p></blockquote>
<p><a href="http://joelabrahamsson.com/">Joel Abrahamsson</a> has done a superb job with the project and is <a href="http://pagetypebuilder.codeplex.com/SourceControl/list/changesets">continually working on it</a>. I&#8217;ve earlier blogged a little about the project in my <a href="http://www.frederikvig.com/2009/12/introduction-create-an-episerver-site-from-scratch/">Create an EPiServer site from scratch series</a>, but not done a proper walk-through.</p>
<h3>New page type</h3>
<p>Creating a new page type is very easy. You create a new class, inherit from TypedPageData, and add the [PageType] attribute to the class declaration (living inside the PageTypeBuilder namespace). You have properties for setting the different page type settings.</p>
<ul>
<li>AvailableInEditMode &#8211; bool (default true)</li>
<li>AvailablePageTypes &#8211; Type[]</li>
<li>DefaultArchiveToPageID &#8211; int (default -1)</li>
<li>DefaultChildSortOrder &#8211; <a href="http://sdk.episerver.com/library/cms5/html/T_EPiServer_Filters_FilterSortOrder.htm">FilterSortOrder</a></li>
<li>DefaultFrameID &#8211; int</li>
<li>DefaultPageName &#8211; string</li>
<li>DefaultSortIndex &#8211; int (default -1)</li>
<li>DefaultStartPublishOffsetMinutes &#8211; int</li>
<li>DefaultStopPublishOffsetMinutes &#8211; int</li>
<li>DefaultVisibleInMenu &#8211; bool (default true)</li>
<li>Description &#8211; string</li>
<li>Filename &#8211; string</li>
<li>Name &#8211; string</li>
<li>SortOrder &#8211; string (default 100)</li>
</ul>
<h4>Example</h4>

<div class="wp_syntax"><div class="code"><pre class="csharp" style="font-family:monospace;"><span style="color: #0600FF;">using</span> <span style="color: #008080;">PageTypeBuilder</span><span style="color: #008000;">;</span>
&nbsp;
<span style="color: #0600FF;">namespace</span> EPiServer.<span style="color: #0000FF;">Templates</span>.<span style="color: #0600FF;">Public</span>.<span style="color: #0000FF;">PageTypes</span>
<span style="color: #000000;">&#123;</span>
    <span style="color: #000000;">&#91;</span>PageType<span style="color: #000000;">&#40;</span>Name <span style="color: #008000;">=</span> <span style="color: #666666;">&quot;[Public] Document list&quot;</span>, SortOrder <span style="color: #008000;">=</span> <span style="color: #FF0000;">1140</span>, Filename <span style="color: #008000;">=</span> <span style="color: #666666;">&quot;/Templates/Public/Pages/DocumentList.aspx&quot;</span>, AvailablePageTypes <span style="color: #008000;">=</span> <span style="color: #008000;">new</span> <span style="color: #000000;">&#91;</span><span style="color: #000000;">&#93;</span> <span style="color: #000000;">&#123;</span> <span style="color: #008000;">typeof</span><span style="color: #000000;">&#40;</span>Document<span style="color: #000000;">&#41;</span><span style="color: #000000;">&#125;</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">&#93;</span>
    <span style="color: #0600FF;">public</span> <span style="color: #FF0000;">class</span> DocumentList <span style="color: #008000;">:</span> TypedPageData
    <span style="color: #000000;">&#123;</span>
    <span style="color: #000000;">&#125;</span>
<span style="color: #000000;">&#125;</span></pre></div></div>

</ul>
<p>For a nice overview of how these properties map to the UI in EPiServer admin mode see: <a href="http://joelabrahamsson.com/entry/how-the-pagetypeattributes-properties-map-to-episerver-cms-admin">How the PageTypeAttribute’s Properties Map to EPiServer CMS’ Admin</a></p>
<h3>Adding properties</h3>
<p>You add properties to a page type by adding new public virtual properties to the class with the [PageTypeProperty] attribute. You have properties for setting the various EPiServer property settings.</p>
<ul>
<li>ClearAllLongStringSettings &#8211; bool</li>
<li>DefaultValue &#8211; string</li>
<li>DefaultValueType &#8211; <a href="http://sdk.episerver.com/library/cms5/html/T_EPiServer_DataAbstraction_DefaultValueType.htm">DefaultValueType</a></li>
<li>DisplayInEditMode &#8211; bool (default true)</li>
<li>EditCaption &#8211; string</li>
<li>HelpText &#8211; string</li>
<li>LongStringSettings &#8211; <a href="http://sdk.episerver.com/library/cms5/html/T_EPiServer_Editor_EditorToolOption.htm">EditorToolOption</a></li>
<li>Required &#8211; bool</li>
<li>Searchable &#8211; bool</li>
<li>SortOrder &#8211; int</li>
<li>Tab &#8211; Type</li>
<li>Type &#8211; Type</li>
<li>UniqueValuePerLanguage &#8211; bool</li>
</ul>
<h4>Example</h4>

<div class="wp_syntax"><div class="code"><pre class="csharp" style="font-family:monospace;"><span style="color: #000000;">&#91;</span>PageTypeProperty<span style="color: #000000;">&#40;</span>
    EditCaption <span style="color: #008000;">=</span> <span style="color: #666666;">&quot;Secondary body&quot;</span>,
    HelpText <span style="color: #008000;">=</span> <span style="color: #666666;">&quot;The contents of this property will be shown in the right column of the page, you can use both text and images for layout. Note that images should not be larger than the right area.&quot;</span>,
    Searchable <span style="color: #008000;">=</span> <span style="color: #0600FF;">true</span>,
    UniqueValuePerLanguage <span style="color: #008000;">=</span> <span style="color: #0600FF;">true</span>,
    Type <span style="color: #008000;">=</span> <span style="color: #008000;">typeof</span><span style="color: #000000;">&#40;</span>PropertyXhtmlString<span style="color: #000000;">&#41;</span>,
    LongStringSettings <span style="color: #008000;">=</span> <span style="color: #000000;">&#40;</span>
	EditorToolOption.<span style="color: #0000FF;">All</span> <span style="color: #008000;">^</span>
	EditorToolOption.<span style="color: #0000FF;">Font</span><span style="color: #000000;">&#41;</span>,
    Tab <span style="color: #008000;">=</span> <span style="color: #008000;">typeof</span><span style="color: #000000;">&#40;</span>Advanced<span style="color: #000000;">&#41;</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">&#93;</span>
<span style="color: #0600FF;">public</span> <span style="color: #0600FF;">virtual</span> <span style="color: #FF0000;">string</span> SecondaryBody
<span style="color: #000000;">&#123;</span>
    get<span style="color: #008000;">;</span>
    set<span style="color: #008000;">;</span>
<span style="color: #000000;">&#125;</span></pre></div></div>

<p>This will add a new property named SecondaryBody of type PropertyXhtmlString (XHTML string (>255)), with all editor options available, except for font. Use ^ for not available, or just add all the options you like with | between.</p>

<div class="wp_syntax"><div class="code"><pre class="csharp" style="font-family:monospace;">LongStringSettings <span style="color: #008000;">=</span> <span style="color: #000000;">&#40;</span>EditorToolOption.<span style="color: #0000FF;">DynamicContent</span> <span style="color: #008000;">|</span> EditorToolOption.<span style="color: #0000FF;">ToggleHtml</span><span style="color: #000000;">&#41;</span></pre></div></div>

<p>Only DynamicContent and ToggleHtml will now be available for editors.</p>
<h4>UniqueValuePerLanguage = false</h4>
<p>When setting UniqueValuePerLanguage to false, and using the auto get setter property (like above), you&#8217;ll get null values returned on properties in other languages than the master language. To fix this you can use the GetPropertyValue extension method.</p>

<div class="wp_syntax"><div class="code"><pre class="csharp" style="font-family:monospace;"><span style="color: #000000;">&#91;</span>PageTypeProperty<span style="color: #000000;">&#40;</span>UniqueValuePerLanguage <span style="color: #008000;">=</span> <span style="color: #0600FF;">false</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">&#93;</span>
<span style="color: #0600FF;">public</span> <span style="color: #FF0000;">string</span> MyProperty
<span style="color: #000000;">&#123;</span>
    get 
    <span style="color: #000000;">&#123;</span> 
        <span style="color: #0600FF;">return</span> <span style="color: #0600FF;">this</span>.<span style="color: #0000FF;">GetPropertyValue</span><span style="color: #000000;">&#40;</span>page <span style="color: #008000;">=&gt;</span> page.<span style="color: #0000FF;">MyProperty</span>, <span style="color: #0600FF;">true</span><span style="color: #000000;">&#41;</span> 
    <span style="color: #000000;">&#125;</span>
<span style="color: #000000;">&#125;</span></pre></div></div>

<p>You should now get the proper value in all languages, not just in the master language.</p>
<h3>Tabs</h3>
<p>To create a new tab, create a new class and inherit from Tab (PageTypeBuilder.Tab). You now need to implement three abstract properties</p>
<ul>
<li>Name &#8211; string</li>
<li>RequiredAccess &#8211; <a href="http://sdk.episerver.com/library/cms5/html/T_EPiServer_Security_AccessLevel.htm">AccessLevel</a></li>
<li>SortIndex &#8211; int</li>
</ul>
<h4>Example</h4>

<div class="wp_syntax"><div class="code"><pre class="csharp" style="font-family:monospace;"><span style="color: #0600FF;">using</span> <span style="color: #008080;">EPiServer.Security</span><span style="color: #008000;">;</span>
<span style="color: #0600FF;">using</span> <span style="color: #008080;">PageTypeBuilder</span><span style="color: #008000;">;</span>
&nbsp;
<span style="color: #0600FF;">namespace</span> EPiServer.<span style="color: #0000FF;">Templates</span>.<span style="color: #0600FF;">Public</span>.<span style="color: #0000FF;">Tabs</span>
<span style="color: #000000;">&#123;</span>
    <span style="color: #0600FF;">public</span> <span style="color: #FF0000;">class</span> Advanced <span style="color: #008000;">:</span> Tab
    <span style="color: #000000;">&#123;</span>
        <span style="color: #0600FF;">public</span> <span style="color: #0600FF;">override</span> <span style="color: #FF0000;">string</span> Name
        <span style="color: #000000;">&#123;</span>
            get <span style="color: #000000;">&#123;</span> <span style="color: #0600FF;">return</span> <span style="color: #666666;">&quot;Advanced&quot;</span><span style="color: #008000;">;</span> <span style="color: #000000;">&#125;</span>
        <span style="color: #000000;">&#125;</span>
&nbsp;
        <span style="color: #0600FF;">public</span> <span style="color: #0600FF;">override</span> AccessLevel RequiredAccess
        <span style="color: #000000;">&#123;</span>
            get <span style="color: #000000;">&#123;</span> <span style="color: #0600FF;">return</span> AccessLevel.<span style="color: #0000FF;">Edit</span><span style="color: #008000;">;</span> <span style="color: #000000;">&#125;</span>
        <span style="color: #000000;">&#125;</span>
&nbsp;
        <span style="color: #0600FF;">public</span> <span style="color: #0600FF;">override</span> <span style="color: #FF0000;">int</span> SortIndex
        <span style="color: #000000;">&#123;</span>
            get <span style="color: #000000;">&#123;</span> <span style="color: #0600FF;">return</span> <span style="color: #FF0000;">20</span><span style="color: #008000;">;</span> <span style="color: #000000;">&#125;</span>
        <span style="color: #000000;">&#125;</span>
    <span style="color: #000000;">&#125;</span>
<span style="color: #000000;">&#125;</span></pre></div></div>

<p>You can now add properties to this tab by setting the PageTypeProperty&#8217;s Tab property.</p>

<div class="wp_syntax"><div class="code"><pre class="csharp" style="font-family:monospace;"><span style="color: #000000;">&#91;</span>PageTypeProperty<span style="color: #000000;">&#40;</span>Tab <span style="color: #008000;">=</span> <span style="color: #008000;">typeof</span><span style="color: #000000;">&#40;</span>Advanced<span style="color: #000000;">&#41;</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">&#93;</span>
<span style="color: #0600FF;">public</span> <span style="color: #0600FF;">virtual</span> <span style="color: #FF0000;">string</span> MyProperty
<span style="color: #000000;">&#123;</span>
    get<span style="color: #008000;">;</span> set<span style="color: #008000;">;</span>
<span style="color: #000000;">&#125;</span></pre></div></div>

<h3>Dynamic properties</h3>
<p>At the moment you cannot create dynamic properties with PageTypeBuilder. You can however access them.</p>

<div class="wp_syntax"><div class="code"><pre class="csharp" style="font-family:monospace;"><span style="color: #0600FF;">public</span> <span style="color: #0600FF;">virtual</span> <span style="color: #FF0000;">string</span> MetaDescription
<span style="color: #000000;">&#123;</span>
    get
    <span style="color: #000000;">&#123;</span>
	<span style="color: #0600FF;">return</span> <span style="color: #0600FF;">this</span>.<span style="color: #0000FF;">GetPropertyValue</span><span style="color: #000000;">&#40;</span>page <span style="color: #008000;">=&gt;</span> page.<span style="color: #0000FF;">MetaDescription</span>, <span style="color: #0600FF;">true</span><span style="color: #000000;">&#41;</span><span style="color: #008000;">;</span>
    <span style="color: #000000;">&#125;</span>
<span style="color: #000000;">&#125;</span></pre></div></div>

<p>As you&#8217;ll see when going through EPiServer public templates with PageTypeBuilder code, I&#8217;ve added the dynamic properties to a base class that the other page types inherit from. That way all page types have access to the dynamic properties.</p>
<p>Also be sure to read: <a href="http://joelabrahamsson.com/entry/working-with-dynamic-properties-and-page-type-builder">Working with Dynamic Properties and Page Type Builder</a>.</p>
<h3>Accessing properties in templates</h3>
<p>One of the great things about the PageTypeBuilder is that you not get strongly typed access to your properties.</p>
<h4>Web forms (.aspx)</h4>
<p>Inherit from the generic TemplatePage (living inside the PageTypeBuilder.UI namespace), where the type is set to the page type this template is for.</p>

<div class="wp_syntax"><div class="code"><pre class="csharp" style="font-family:monospace;"><span style="color: #0600FF;">using</span> <span style="color: #008080;">PageTypeBuilder.UI</span><span style="color: #008000;">;</span>
&nbsp;
<span style="color: #0600FF;">namespace</span> EPiServer.<span style="color: #0000FF;">Templates</span>.<span style="color: #0600FF;">Public</span>.<span style="color: #0000FF;">Pages</span>
<span style="color: #000000;">&#123;</span>
    <span style="color: #0600FF;">public</span> <span style="color: #0600FF;">partial</span> <span style="color: #FF0000;">class</span> Document <span style="color: #008000;">:</span> TemplatePage<span style="color: #008000;">&lt;</span>PageTypes.<span style="color: #0000FF;">Document</span><span style="color: #008000;">&gt;</span>
    <span style="color: #000000;">&#123;</span>
    <span style="color: #000000;">&#125;</span>
<span style="color: #000000;">&#125;</span></pre></div></div>

<p>When typing CurrentPage. you&#8217;ll get access to all the public properties that Document exposes. CurrentPage.SecondaryBody for instance.</p>
<h4>User controls (.ascx)</h4>
<p>Inherit from the generic UserControlBase (living inside the PageTypeBuilder.UI namespace), where the type is set to the page type this user control is for. If the user control is used by multiple page types, simply find a common class to set as the type (a base class).</p>

<div class="wp_syntax"><div class="code"><pre class="csharp" style="font-family:monospace;"><span style="color: #0600FF;">using</span> <span style="color: #008080;">PageTypeBuilder.UI</span><span style="color: #008000;">;</span>
&nbsp;
<span style="color: #0600FF;">namespace</span> EPiServer.<span style="color: #0000FF;">Templates</span>.<span style="color: #0600FF;">Public</span>.<span style="color: #0000FF;">Units</span>.<span style="color: #0000FF;">Placeable</span>
<span style="color: #000000;">&#123;</span>
    <span style="color: #0600FF;">public</span> <span style="color: #0600FF;">partial</span> <span style="color: #FF0000;">class</span> Document <span style="color: #008000;">:</span> UserControlBase<span style="color: #008000;">&lt;</span>PageTypes.<span style="color: #0000FF;">BasePageData</span><span style="color: #008000;">&gt;</span>
    <span style="color: #000000;">&#123;</span>
    <span style="color: #000000;">&#125;</span>
<span style="color: #000000;">&#125;</span></pre></div></div>

<p>Same as with web forms, you&#8217;ll get access the the properties that BasePageData exposes.</p>
<h3>EPiServer public templates with PageTypeBuilder</h3>
<p>I&#8217;ve started updating the EPiServer public templates to use PageTypeBuilder. This is not a complete conversion, but merely a nice starting place for you to see how I&#8217;ve structured my files and how the code looks when used with an existing project.</p>
<p><a href="http://www.frederikvig.com/wp-content/uploads/pagetypebuilder/PublicTemplatesWithPageTypeBuilder.zip">Download the code</a></p>
<h3>Other resources</h3>
<ul>
<li><a href="http://pagetypebuilder.codeplex.com/">EPiServer CMS Page Type Builder project home</a> &#8211; you&#8217;ll also find a nice up-to-date list of links to additional resources there.</li>
</ul>
<p><strong>Related Posts:</strong>
<ul class="similar-posts">
<li><a href="http://www.frederikvig.com/2009/12/part-6-creating-the-xform-page-create-an-episerver-site-from-scratch/" rel="bookmark" title="December 19, 2009">Part 6: Creating the XForm page – Create an EPiServer site from scratch</a></li>
<li><a href="http://www.frederikvig.com/2009/12/part-5-creating-the-search-page-create-an-episerver-site-from-scratch/" rel="bookmark" title="December 16, 2009">Part 5: Creating the search page – Create an EPiServer site from scratch</a></li>
<li><a href="http://www.frederikvig.com/2009/12/part-7-creating-the-sitemap-page-create-an-episerver-site-from-scratch/" rel="bookmark" title="December 22, 2009">Part 7: Creating the Sitemap page – Create an EPiServer site from scratch</a></li>
<li><a href="http://www.frederikvig.com/2009/12/part-2-creating-a-foundation-create-an-episerver-site-from-scratch/" rel="bookmark" title="December 7, 2009">Part 2: Creating a foundation &#8211; Create an EPiServer site from scratch</a></li>
<li><a href="http://www.frederikvig.com/2009/11/flash-and-flash-video-episerver-dynamic-content/" rel="bookmark" title="November 17, 2009">Flash and Flash Video EPiServer Dynamic Content</a></li>
</ul>
<p><!-- Similar Posts took 85.090 ms --></p>
<img src="http://feeds.feedburner.com/~r/frederikvig/~4/ym7WramAUDw" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.frederikvig.com/2010/01/a-developers-guide-to-pagetypebuilder/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		<feedburner:origLink>http://www.frederikvig.com/2010/01/a-developers-guide-to-pagetypebuilder/</feedburner:origLink></item>
		<item>
		<title>2010</title>
		<link>http://feedproxy.google.com/~r/frederikvig/~3/zB8RdlK64tE/</link>
		<comments>http://www.frederikvig.com/2010/01/2010/#comments</comments>
		<pubDate>Sat, 09 Jan 2010 18:41:34 +0000</pubDate>
		<dc:creator>Frederik Vig</dc:creator>
				<category><![CDATA[Personal]]></category>
		<category><![CDATA[Blogging]]></category>
		<category><![CDATA[Freelancing]]></category>

		<guid isPermaLink="false">http://www.frederikvig.com/?p=1003</guid>
		<description><![CDATA[Happy new year everyone! Just got back from an excellent vacation in New York, USA. Feel very rested and looking forward to getting back to work! Some updates: I received the EMVP (EPiServer Most Valued Professional) status, started out on my own as a freelance ASP.NET developer, and created the first EPiServer meetup group in [...]]]></description>
			<content:encoded><![CDATA[<p>Happy new year everyone! Just got back from an excellent vacation in New York, USA. Feel very rested and looking forward to getting back to work! Some updates: I received the <a href="http://labs.episerver.com/en/EMVP/The-EMVP-list/">EMVP (EPiServer Most Valued Professional) status</a>, started out on my own as a freelance ASP.NET developer, and created the first <a href="http://www.meetup.com/EPiServer-developers-in-Oslo/">EPiServer meetup group in Norway</a>. </p>
<p>The biggest change for me was starting out on my own. I&#8217;m about to sign a contract for three months with a local EPiServer partner here in Oslo, for them to contract me 3-4 days a week. The other 1-2 days I&#8217;m going to spend working on an EPiServer module (more information to come) for EPiServer CMS 6. </p>
<p>My goal for this blog is to roughly write a blog post once a week (sometimes more, sometimes less). Mostly focusing on ASP.NET and EPiServer stuff, but also more content on other subjects, reflecting what I&#8217;m focusing on at the moment. </p>
<p>I&#8217;m a firm believer that when you only focus on one thing, you tend to only see things through one perspective. In 2010 I&#8217;m going to explore more outside my comfort zone and what I usually work with. Some of the things that I&#8217;m exploring at the moment: The <a href="http://www.djangoproject.com/">Django framework</a>, <a href="http://php.net/index.php">PHP</a> (building a time tracking application for my freelance business), I just received <a href="http://docs.google.com/View?docID=0ARRbNRjSHxxUZGhtdzlodHBfMGRiNXo0N2hw&#038;revision=_latest">a few books</a> that I&#8217;m reading, and I&#8217;m going to explore more of <a href="http://umbraco.org/">Umbraco</a> (hopefully getting certified in Umbraco this spring). I think all of this will help me become a better developer, and help me with my daily work. I will of course try to share my experiences with you on this blog.</p>
<p>The <a href="http://www.frederikvig.com/2009/12/introduction-create-an-episerver-site-from-scratch/">Create an EPiServer site from scratch</a> was a huge success, with lots of great feedback. Very inspiring for me, giving me lots of ideas for further series. Thanks for all the comments, and keep them coming!</p>
<p>With the <a href="http://www.meetup.com/EPiServer-developers-in-Oslo/">EPiServer meetup group in Oslo</a> I hope to meet more of the rest of the community in Norway. One of the things I&#8217;ve missed is a community here in Oslo. I think I actually know more EPiServer developers in Sweden than in Norway.. the traffic to this blog actually back that up, 4 times as many from Sweden than from Norway. Hopefully this will change with the meetup group, allowing me to meet all the cool EPiServer developers that I know are out there <img src='http://www.frederikvig.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> .</p>
<p>Another thing this year is redesigning of my blog. I&#8217;m not a designer, so this will be a fun and new experience, again outside my comfort zone, but something I think I&#8217;ll learn a lot from. I have a few Photoshop DVD courses that I&#8217;m going to go through, learning Photoshop even more, helping me with the redesign and with manipulating the pictures I use in my blog posts. </p>
<p>Since I&#8217;m my own boss I&#8217;m using Fridays as a &#8220;do what you want day&#8221;, either taking a long weekend and going somewhere, blogging, redesigning, or any of my other projects. I think this will help me focus and work even better the rest of the week. </p>
<p>Lots of projects and ideas! Very excited to get started and learn even more this year than the last! Thanks for all your support and great comments last year! I&#8217;ll do my best to create an even better blog this year!</p>
<p> <strong>Related Posts:</strong>
<ul class="similar-posts">
<li><a href="http://www.frederikvig.com/2010/02/guide-to-font-sizing-with-css/" rel="bookmark" title="February 6, 2010">Guide to font sizing with CSS</a></li>
<li><a href="http://www.frederikvig.com/2010/01/episerver-code-walkthrough-1-404-handler/" rel="bookmark" title="January 29, 2010">EPiServer code walkthrough #1 &#8211; 404 handler</a></li>
<li><a href="http://www.frederikvig.com/2009/12/part-7-creating-the-sitemap-page-create-an-episerver-site-from-scratch/" rel="bookmark" title="December 22, 2009">Part 7: Creating the Sitemap page – Create an EPiServer site from scratch</a></li>
<li><a href="http://www.frederikvig.com/2009/10/font-resizing-and-printing-with-jquery/" rel="bookmark" title="October 27, 2009">Font resizing and printing with jQuery</a></li>
<li><a href="http://www.frederikvig.com/2009/12/part-3-creating-the-start-page-create-an-episerver-site-from-scratch/" rel="bookmark" title="December 10, 2009">Part 3: Creating the start page – Create an EPiServer site from scratch</a></li>
</ul>
<p><!-- Similar Posts took 17.766 ms --></p>
<img src="http://feeds.feedburner.com/~r/frederikvig/~4/zB8RdlK64tE" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.frederikvig.com/2010/01/2010/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		<feedburner:origLink>http://www.frederikvig.com/2010/01/2010/</feedburner:origLink></item>
		<item>
		<title>Part 8: Preparing for launch – Create an EPiServer site from scratch</title>
		<link>http://feedproxy.google.com/~r/frederikvig/~3/xMgt01_iUkE/</link>
		<comments>http://www.frederikvig.com/2009/12/part-8-preparing-for-launch-create-an-episerver-site-from-scratch/#comments</comments>
		<pubDate>Wed, 23 Dec 2009 23:01:57 +0000</pubDate>
		<dc:creator>Frederik Vig</dc:creator>
				<category><![CDATA[EPiServer]]></category>
		<category><![CDATA[EPiServer site]]></category>

		<guid isPermaLink="false">http://www.frederikvig.com/?p=513</guid>
		<description><![CDATA[This is the last part of Create an EPiServer site from scratch. We&#8217;ve come a long way, almost finishing our site! What we have left is doing some testing and deploying it to our production server.
Client side performance testing
When doing performance testing, we as ASP.NET developers, mostly focus on the server side stuff. EPiServer has [...]]]></description>
			<content:encoded><![CDATA[<p>This is the last part of Create an EPiServer site from scratch. We&#8217;ve come a long way, almost finishing our site! What we have left is doing some testing and deploying it to our production server.</p>
<h3>Client side performance testing</h3>
<p>When doing performance testing, we as ASP.NET developers, mostly focus on the server side stuff. EPiServer has done a superb job with making sure that EPiServer looks after server side performance for you, and gives you the tools to improve it even more. But one area of performance we don&#8217;t necessarily focus so much on is client side performance. </p>
<p>With client side performance I mean how fast the transfer to the client (user) is. Most of the users time will not be spent waiting for a SQL query to run, but actually downloading all the sites resources (images, css, JavaScript files etc). </p>
<p>There are some easy steps we can take to improve our site even more. Lets start by taking a look at <a href="http://developer.yahoo.com/performance/rules.html">Yahoo!&#8217;s Best Practices rules for Speeding up our site</a>. There are some very good rules here that we&#8217;ll implement. Yahoo! has also developed a Firefox extension <a href="http://developer.yahoo.com/yslow/">YSlow</a> for Firebug. </p>
<h4>YSlow</h4>
<p>Install YSlow, and run it by pressing the YSlow button in the bottom right corner of Firefox.</p>
<p>
<img src="http://www.frederikvig.com/wp-content/uploads/jungle-site/part8/yslow.png" alt="YSlow in Firefox" />
</p>
<p>Click the YSlow tab and Run Test. </p>
<p><img src="http://www.frederikvig.com/wp-content/uploads/jungle-site/part8/yslow-result1.png" alt="YSlow result" /></p>
<p>Overall we have a result of C, which is fine, but as you can see we have a few F&#8217;s around. </p>
<h4>ETags</h4>
<blockquote><p>
<cite>From YSlow rules</cite></p>
<p>Entity tags (ETags) are a mechanism web servers and the browser use to determine whether a component in the browser&#8217;s cache matches one on the origin server. Since ETags are typically constructed using attributes that make them unique to a specific server hosting a site, the tags will not match when a browser gets the original component from one server and later tries to validate that component on a different server.</p>
</blockquote>
<p>To remove the ETags in IIS 7, open up the IIS Manager, go to the Jungle site, and click HTTP Response Headers, click Add and type ETag into the name and &#8220;&#8221; into the Value field. </p>
<p><img src="http://www.frederikvig.com/wp-content/uploads/jungle-site/part8/iis-etag.png" alt="Remove ETags in IIS 7" /></p>
<h4>Expires HTTP headers</h4>
<p><a href="http://world.episerver.com/System/Users-and-profiles/Community-Profile-Card/?encryptedcurrentid=/nGBxvNNDik%3d">Per Bjurström</a> has written on this before, <a href="http://labs.episerver.com/en/Blogs/Per/Archive/2009/3/Configuring-cache-expiration-on-IIS-7/">Configuring cache expiration on IIS 7</a>. </p>
<p>I updated the staticContent sections clientCache to.</p>

<div class="wp_syntax"><div class="code"><pre class="xml" style="font-family:monospace;"><span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;staticContent<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;clientCache</span> <span style="color: #000066;">cacheControlMode</span>=<span style="color: #ff0000;">&quot;UseExpires&quot;</span> <span style="color: #000066;">httpExpires</span>=<span style="color: #ff0000;">&quot;Sun, 29 Mar 2020 00:00:00 GMT&quot;</span> <span style="color: #000000; font-weight: bold;">/&gt;</span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/staticContent<span style="color: #000000; font-weight: bold;">&gt;</span></span></span></pre></div></div>

<p>Which sets the expiration date to 2020 on static content (CSS, JavaScript, PNGs etc).</p>
<p><img src="http://www.frederikvig.com/wp-content/uploads/jungle-site/part8/expires-header.png" alt="Expires header with Network monitor in Firebug" /></p>
<p>If your using IIS 6, you can use a custom static file handler.</p>

<div class="wp_syntax"><div class="code"><pre class="csharp" style="font-family:monospace;"><span style="color: #0600FF;">using</span> <span style="color: #008080;">System</span><span style="color: #008000;">;</span>
<span style="color: #0600FF;">using</span> <span style="color: #008080;">System.Web</span><span style="color: #008000;">;</span>
&nbsp;
<span style="color: #0600FF;">namespace</span> Jungle
<span style="color: #000000;">&#123;</span>
    <span style="color: #0600FF;">public</span> <span style="color: #FF0000;">class</span> JungleStaticFileHandler <span style="color: #008000;">:</span> EPiServer.<span style="color: #0000FF;">Web</span>.<span style="color: #0000FF;">StaticFileHandler</span>
    <span style="color: #000000;">&#123;</span>
        <span style="color: #0600FF;">protected</span> <span style="color: #0600FF;">override</span> <span style="color: #0600FF;">void</span> SetCachePolicy<span style="color: #000000;">&#40;</span>HttpContext context, DateTime fileChangedDate<span style="color: #000000;">&#41;</span>
        <span style="color: #000000;">&#123;</span>
            <span style="color: #0600FF;">if</span> <span style="color: #000000;">&#40;</span>fileChangedDate <span style="color: #008000;">&gt;</span> DateTime.<span style="color: #0000FF;">UtcNow</span><span style="color: #000000;">&#41;</span>
            <span style="color: #000000;">&#123;</span>
                fileChangedDate <span style="color: #008000;">=</span> DateTime.<span style="color: #0000FF;">UtcNow</span><span style="color: #008000;">;</span>
            <span style="color: #000000;">&#125;</span>
            context.<span style="color: #0000FF;">Response</span>.<span style="color: #0000FF;">Cache</span>.<span style="color: #0000FF;">SetLastModified</span><span style="color: #000000;">&#40;</span>fileChangedDate<span style="color: #000000;">&#41;</span><span style="color: #008000;">;</span>
            context.<span style="color: #0000FF;">Response</span>.<span style="color: #0000FF;">Cache</span>.<span style="color: #0000FF;">SetCacheability</span><span style="color: #000000;">&#40;</span>HttpCacheability.<span style="color: #0600FF;">Public</span><span style="color: #000000;">&#41;</span><span style="color: #008000;">;</span>
            context.<span style="color: #0000FF;">Response</span>.<span style="color: #0000FF;">Cache</span>.<span style="color: #0000FF;">SetExpires</span><span style="color: #000000;">&#40;</span>DateTime.<span style="color: #0000FF;">UtcNow</span>.<span style="color: #0000FF;">AddYears</span><span style="color: #000000;">&#40;</span><span style="color: #FF0000;">1</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">&#41;</span><span style="color: #008000;">;</span>
            context.<span style="color: #0000FF;">Response</span>.<span style="color: #0000FF;">Cache</span>.<span style="color: #0000FF;">SetValidUntilExpires</span><span style="color: #000000;">&#40;</span><span style="color: #0600FF;">true</span><span style="color: #000000;">&#41;</span><span style="color: #008000;">;</span>
            context.<span style="color: #0000FF;">Response</span>.<span style="color: #0000FF;">Cache</span>.<span style="color: #0000FF;">VaryByParams</span>.<span style="color: #0000FF;">IgnoreParams</span> <span style="color: #008000;">=</span> true<span style="color: #008000;">;</span>
            context.<span style="color: #0000FF;">Response</span>.<span style="color: #0000FF;">Cache</span>.<span style="color: #0000FF;">SetOmitVaryStar</span><span style="color: #000000;">&#40;</span><span style="color: #0600FF;">true</span><span style="color: #000000;">&#41;</span><span style="color: #008000;">;</span>
        <span style="color: #000000;">&#125;</span>
    <span style="color: #000000;">&#125;</span>
<span style="color: #000000;">&#125;</span></pre></div></div>

<p>For some reason you can only add 1 year when doing this with a custom handler. You also need to update the web.config file to use JungleStaticFileHandler instead of StaticFileHandler.</p>
<h4>CDN Support</h4>
<p>Per Bjurström has another terrific post explaining how to <a href="http://world.episerver.com/en/Blogs/Per-Bjurstrom/Archive/2009/5/CdnSupport-module-preview-2/">enable CDN for EPiServer</a>. I&#8217;ve not enabled it for my local site, but if you do, just remember that you don&#8217;t need to use JungleStaticFileHandler anymore, since CdnStaticFileHandler does the same thing.</p>
<h4>Fewer HTTP requests</h4>
<p>We can easily reduce our HTTP requests by combining our CSS or JavaScript files into one, and by using CSS Sprites. To help with the CSS Sprites there are quite a <a href="http://www.google.com/#hl=en&#038;source=hp&#038;q=css+sprites+generator&#038;aq=1&#038;aqi=g10&#038;oq=css+sprites&#038;fp=cbc2f75bf9d43a8f">few generators</a> out there. I encourage you to take a look and try it out, this is one of the most important steps you can take for better client side performance.</p>
<h4>Compressing CSS and JavaScript</h4>
<p>To compress CSS and JavaScript code we can add either add an HTTP Handler that does this for us, use an online compressor, or add a build task to Visual Studio.</p>
<p>There are a number of resources to help you with compressing CSS and JavaScript files, many of them also combine CSS or JavaScript files into one. </p>
<ul>
<li><a href="http://www.codeplex.com/YUICompressor">Yahoo! UI Library: YUI Compressor for .Net</a></li>
<li><a href="http://www.codeproject.com/KB/aspnet/HttpCombine.aspx">HTTP Handler to Combine Multiple Files, Cache and Deliver Compressed Output for Faster Page Load</a></li>
</ul>
<h3>From local development to remote server</h3>
<p>We&#8217;re now ready to deploy our application to a remote server. Open up <a href="http://www.eworldui.net/unleashit/">UnleashIt</a> (install it if you haven&#8217;t done so already). </p>
<p>Create a new profile by going to: File, Profiles, Profile Configuration. Select the Quick Deploy Profile, duplicate it, and give it a name of Jungle. Click OK, and go back to the main UnleashIt window. Under Source destination select your wwwroot folder and choose a destination folder.</p>
<p>
<img src="http://www.frederikvig.com/wp-content/uploads/jungle-site/part8/unleash-it.png" alt="UnleashIt profile" />
</p>
<p>If this is the first time you use UnleashIt you need to add a few File Masks (files UnleashIt copies over to the deployment folder). To add new ones go back to Profile Configuration (File, Profiles, Profile Configuration). You have a text field where you can type new file masks, add them by clicking the Add as file mask button. </p>
<h4>My file masks</h4>
<ul>
<li>*.asax</li>
<li>*.ascx</li>
<li>*.ashx</li>
<li>*.asmx</li>
<li>*.aspx</li>
<li>*.browser</li>
<li>*.config</li>
<li>*.css</li>
<li>*.dll</li>
<li>*.gif</li>
<li>*.htm</li>
<li>*.html</li>
<li>*.ico</li>
<li>*.jpg</li>
<li>*.js</li>
<li>*.master</li>
<li>*.png</li>
<li>*.skin</li>
<li>*.txt</li>
<li>*.xml</li>
</ul>
<h4>Database</h4>
<p>Take a backup of your development database by using the SQL Server Management Studio (can be installed with Web Platform installer). Right-click the database, and choose Tasks, Back Up (make sure the backup type is set to full).</p>
<p><img src="http://www.frederikvig.com/wp-content/uploads/jungle-site/part8/database-backup.png" alt="Database backup with SQL Server Management Studio" /></p>
<p>Connect to your production database server/instance, create a new database and restore the database by going to: Tasks, Restore, Database. Select from Device and choose our database (dbJungle.bak in my case), check the checkbox next to the backup set to restore. Go to Options and check the checkbox next to Overwrite the existing database, also update the Restore the database files as paths.</p>
<p>Great, we can now click OK, and the restore will start. After you&#8217;ve restored successfully, remember to add a user to the db_owner schema. Expand the the database and choose Security, Users, and either add a new one or update the existing one.</p>
<p>
<a href="http://www.frederikvig.com/wp-content/uploads/jungle-site/part8/database-restore.png"><img src="http://www.frederikvig.com/wp-content/uploads/jungle-site/part8/database-restore.png" alt="Add user to database" width="600" /></a>
</p>
<h4>Remote server</h4>
<p>In my case, I&#8217;m deploying the application to a Windows 2008 Server with IIS 7 (same IIS version as my development one). </p>
<p>Either use remote desktop or login to your remote server in another way. Make sure to install EPiServer on the server if it isn&#8217;t already installed (see <a href="http://www.frederikvig.com/2009/12/part-1-setting-up-the-development-environment-create-an-episerver-site-from-scratch/">Part 1: Setting up the development environment</a> for more information). </p>
<p>Copy the deployed files to the remote server, I usually use a folder system like this on the remote server: Customers\CustomerName\Internet(Intranet)\wwwroot. Also make sure to copy the VPP folders.</p>
<p>Open up the IIS Manager and create a new application pool by going to Application Pools and Add Application Pool, use the default settings (.NET 2, Integrated mode etc). </p>
<p>Now we can create the site in IIS, right-click Sites, and Add Web Site, give it a name and choose our newly created application pool, choose the wwwroot folder, under host names add the host name you wish to use.</p>
<p><img src="http://www.frederikvig.com/wp-content/uploads/jungle-site/part8/new-site-iis.png" alt="New Site in IIS 7" /></p>
<p>We need to update connectionStrings.config with the new connection information (new database, user name, password etc), and web.config with the new VPP paths. Just search for VPP and the first hit should match the PageFiles path (there are three paths to update). Last step is updating siteUrl under siteSettings, to our new host name.</p>
<p>You should now have a running site! Test by clicking a little around to make sure everything works as expected.</p>
<p>Sometimes it takes a while for the DNS of the new domain to get updated everywhere, a little trick is to update your local hosts file (C:\Windows\System32\drivers\etc\hosts), and add the host name with the remote servers IP address.</p>
<h3>Uptime</h3>
<p>There are various tools, both free and commercial, that&#8217;ll tell you when a site goes down. One I&#8217;ve used in the past is the free <a href="http://basicstate.com/">BasicState</a>, you also have <a href="http://pingdom.com/">Pingdom</a> and <a href="http://www.uptrends.com/">Uptrends</a> both are commercial. I recommend giving them a try!</p>
<h3>Logging exceptions</h3>
<blockquote>
<p>ELMAH (Error Logging Modules and Handlers) is an application-wide error logging facility that is completely pluggable. It can be dynamically added to a running ASP.NET web application, or even all ASP.NET web applications on a machine, without any need for re-compilation or re-deployment.</p>
</blockquote>
<p><a href="http://code.google.com/p/elmah/">ELMAH</a> is a free and easy to use and setup, and you can subscribe to a RSS feed for updates. </p>
<h4>ASP.NET Exception Reporter</h4>
<p>Another free tool that is based on ELMAH is <a href="http://aspexceptionreporter.codeplex.com/">ASP.NET Exception Reporter</a>.</p>
<blockquote>
<p>ASP.NET Exception Reporter (based on ELMAH) is pluggable application-wide error logging facility. Plug it in to your existing webapps, webservices, &#8230;<br />
The goal is to centralize the different exceptions that are generated by ELMAH to one web application.<br />
It is developed in C#.</p>
</blockquote>
<p>Great for when you need to monitor multiple applications, not just the one.</p>
<p><img src="http://www.frederikvig.com/wp-content/uploads/jungle-site/part8/elmahws1.png" alt="ASP.NET Exception Reporter" /></p>
<h3>Conclusion</h3>
<p>There are of course numerous tasks and functionality we didn&#8217;t do or add in this series. I&#8217;ve deliberately kept things as simple as possible, and instead tried to give you pointers on how you might extend the site even more. I highly recommend playing around more with the site, and implementing some of the functionality we didn&#8217;t implement. Both the footer and the thumbnail images, are a great place to start.</p>
<p>I hope you&#8217;ve enjoyed this series, and do be sure to come back to this site for further updates and new blog posts!</p>
<p>Thanks for reading! And merry Christmas! <img src='http://www.frederikvig.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' />  <strong>Related Posts:</strong>
<ul class="similar-posts">
<li><a href="http://www.frederikvig.com/2009/05/measuring-javascript-performance/" rel="bookmark" title="May 10, 2009">Measuring JavaScript performance</a></li>
<li><a href="http://www.frederikvig.com/2009/12/introduction-create-an-episerver-site-from-scratch/" rel="bookmark" title="December 1, 2009">Introduction &#8211; Create an EPiServer site from scratch</a></li>
<li><a href="http://www.frederikvig.com/2009/12/part-1-setting-up-the-development-environment-create-an-episerver-site-from-scratch/" rel="bookmark" title="December 4, 2009">Part 1: Setting up the development environment &#8211; Create an EPiServer site from scratch</a></li>
<li><a href="http://www.frederikvig.com/2009/08/adding-css-and-javascript-files-dynamically-to-your-asp-net-page/" rel="bookmark" title="August 15, 2009">Adding CSS and JavaScript files dynamically to your ASP.NET page</a></li>
<li><a href="http://www.frederikvig.com/2009/12/part-2-creating-a-foundation-create-an-episerver-site-from-scratch/" rel="bookmark" title="December 7, 2009">Part 2: Creating a foundation &#8211; Create an EPiServer site from scratch</a></li>
</ul>
<p><!-- Similar Posts took 15.935 ms --></p>
<img src="http://feeds.feedburner.com/~r/frederikvig/~4/xMgt01_iUkE" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.frederikvig.com/2009/12/part-8-preparing-for-launch-create-an-episerver-site-from-scratch/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		<feedburner:origLink>http://www.frederikvig.com/2009/12/part-8-preparing-for-launch-create-an-episerver-site-from-scratch/</feedburner:origLink></item>
		<item>
		<title>Part 7: Creating the Sitemap page – Create an EPiServer site from scratch</title>
		<link>http://feedproxy.google.com/~r/frederikvig/~3/_F0DZStUE1g/</link>
		<comments>http://www.frederikvig.com/2009/12/part-7-creating-the-sitemap-page-create-an-episerver-site-from-scratch/#comments</comments>
		<pubDate>Mon, 21 Dec 2009 23:01:57 +0000</pubDate>
		<dc:creator>Frederik Vig</dc:creator>
				<category><![CDATA[EPiServer]]></category>
		<category><![CDATA[EPiServer site]]></category>

		<guid isPermaLink="false">http://www.frederikvig.com/?p=511</guid>
		<description><![CDATA[We&#8217;re soon ready to launch or site. One thing that is missing is the Sitemap page. This is a page that will help our users find what they&#8217;re looking for, and give them a nice overview of the site structure. 
Create a new page type with these settings and properties.

using EPiServer.Core;
using PageTypeBuilder;
&#160;
namespace Jungle.Templates.Jungle.PageTypes
&#123;
   [...]]]></description>
			<content:encoded><![CDATA[<p>We&#8217;re soon ready to launch or site. One thing that is missing is the Sitemap page. This is a page that will help our users find what they&#8217;re looking for, and give them a nice overview of the site structure. </p>
<p>Create a new page type with these settings and properties.</p>

<div class="wp_syntax"><div class="code"><pre class="csharp" style="font-family:monospace;"><span style="color: #0600FF;">using</span> <span style="color: #008080;">EPiServer.Core</span><span style="color: #008000;">;</span>
<span style="color: #0600FF;">using</span> <span style="color: #008080;">PageTypeBuilder</span><span style="color: #008000;">;</span>
&nbsp;
<span style="color: #0600FF;">namespace</span> Jungle.<span style="color: #0000FF;">Templates</span>.<span style="color: #0000FF;">Jungle</span>.<span style="color: #0000FF;">PageTypes</span>
<span style="color: #000000;">&#123;</span>
    <span style="color: #000000;">&#91;</span>PageType<span style="color: #000000;">&#40;</span>
        Name <span style="color: #008000;">=</span> <span style="color: #666666;">&quot;[Jungle] Sitemap page&quot;</span>,
        Filename <span style="color: #008000;">=</span> <span style="color: #666666;">&quot;/Templates/Jungle/Pages/Sitemap.aspx&quot;</span>,
        SortOrder <span style="color: #008000;">=</span> <span style="color: #FF0000;">1060</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">&#93;</span>
    <span style="color: #0600FF;">public</span> <span style="color: #FF0000;">class</span> SitemapPage <span style="color: #008000;">:</span> EditorialPage
    <span style="color: #000000;">&#123;</span>
        <span style="color: #000000;">&#91;</span>PageTypeProperty<span style="color: #000000;">&#40;</span>
            EditCaption <span style="color: #008000;">=</span> <span style="color: #666666;">&quot;Sitemap root page&quot;</span>,
            Type <span style="color: #008000;">=</span> <span style="color: #008000;">typeof</span><span style="color: #000000;">&#40;</span>PropertyPageReference<span style="color: #000000;">&#41;</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">&#93;</span>
        <span style="color: #0600FF;">public</span> <span style="color: #0600FF;">virtual</span> PageReference SitemapRoot
        <span style="color: #000000;">&#123;</span>
            get<span style="color: #008000;">;</span>
            set<span style="color: #008000;">;</span>
        <span style="color: #000000;">&#125;</span>
    <span style="color: #000000;">&#125;</span>
<span style="color: #000000;">&#125;</span></pre></div></div>

<p>We can now create Sitemap.aspx. I&#8217;m using a PageTree control for generating the site structure (nested ordered lists).</p>

<div class="wp_syntax"><div class="code"><pre class="csharp" style="font-family:monospace;"><span style="color: #008000;">&lt;%</span>@ Page Language<span style="color: #008000;">=</span><span style="color: #666666;">&quot;C#&quot;</span> AutoEventWireup<span style="color: #008000;">=</span><span style="color: #666666;">&quot;true&quot;</span> CodeBehind<span style="color: #008000;">=</span><span style="color: #666666;">&quot;Sitemap.aspx.cs&quot;</span> Inherits<span style="color: #008000;">=</span><span style="color: #666666;">&quot;Jungle.Templates.Jungle.Pages.Sitemap&quot;</span> MasterPageFile<span style="color: #008000;">=</span><span style="color: #666666;">&quot;~/Templates/Jungle/MasterPages/Site.Master&quot;</span> <span style="color: #008000;">%&gt;</span>
<span style="color: #008000;">&lt;%</span>@ Register TagPrefix<span style="color: #008000;">=</span><span style="color: #666666;">&quot;Jungle&quot;</span> TagName<span style="color: #008000;">=</span><span style="color: #666666;">&quot;MainBody&quot;</span> Src<span style="color: #008000;">=</span><span style="color: #666666;">&quot;~/Templates/Jungle/Units/MainBody.ascx&quot;</span> <span style="color: #008000;">%&gt;</span>
<span style="color: #008000;">&lt;</span>asp<span style="color: #008000;">:</span>Content ContentPlaceHolderID<span style="color: #008000;">=</span><span style="color: #666666;">&quot;MainContentRegion&quot;</span> runat<span style="color: #008000;">=</span><span style="color: #666666;">&quot;server&quot;</span><span style="color: #008000;">&gt;</span>
&nbsp;
    <span style="color: #008000;">&lt;</span>EPiServer<span style="color: #008000;">:</span>PageTree runat<span style="color: #008000;">=</span><span style="color: #666666;">&quot;server&quot;</span> ExpandAll<span style="color: #008000;">=</span><span style="color: #666666;">&quot;true&quot;</span> ID<span style="color: #008000;">=</span><span style="color: #666666;">&quot;SitemapTree&quot;</span><span style="color: #008000;">&gt;</span>
        <span style="color: #008000;">&lt;</span>HeaderTemplate<span style="color: #008000;">&gt;</span>
            <span style="color: #008000;">&lt;</span>div id<span style="color: #008000;">=</span><span style="color: #666666;">&quot;Sitemap&quot;</span><span style="color: #008000;">&gt;</span>
        <span style="color: #008000;">&lt;/</span>HeaderTemplate<span style="color: #008000;">&gt;</span>
        <span style="color: #008000;">&lt;</span>IndentTemplate<span style="color: #008000;">&gt;</span>
            <span style="color: #008000;">&lt;</span>ol<span style="color: #008000;">&gt;</span>
        <span style="color: #008000;">&lt;/</span>IndentTemplate<span style="color: #008000;">&gt;</span>
        <span style="color: #008000;">&lt;</span>ItemHeaderTemplate<span style="color: #008000;">&gt;</span>
            <span style="color: #008000;">&lt;</span>li<span style="color: #008000;">&gt;</span>
        <span style="color: #008000;">&lt;/</span>ItemHeaderTemplate<span style="color: #008000;">&gt;</span>
        <span style="color: #008000;">&lt;</span>ItemTemplate<span style="color: #008000;">&gt;</span>
            <span style="color: #008000;">&lt;</span>EPiServer<span style="color: #008000;">:</span>Property PropertyName<span style="color: #008000;">=</span><span style="color: #666666;">&quot;PageLink&quot;</span> runat<span style="color: #008000;">=</span><span style="color: #666666;">&quot;server&quot;</span> <span style="color: #008000;">/&gt;</span>
        <span style="color: #008000;">&lt;/</span>ItemTemplate<span style="color: #008000;">&gt;</span>
        <span style="color: #008000;">&lt;</span>ItemFooterTemplate<span style="color: #008000;">&gt;</span>
            <span style="color: #008000;">&lt;/</span>li<span style="color: #008000;">&gt;</span>
        <span style="color: #008000;">&lt;/</span>ItemFooterTemplate<span style="color: #008000;">&gt;</span>
        <span style="color: #008000;">&lt;</span>UnindentTemplate<span style="color: #008000;">&gt;</span>
            <span style="color: #008000;">&lt;/</span>ol<span style="color: #008000;">&gt;</span>
        <span style="color: #008000;">&lt;/</span>UnindentTemplate<span style="color: #008000;">&gt;</span>
        <span style="color: #008000;">&lt;</span>FooterTemplate<span style="color: #008000;">&gt;</span>
            <span style="color: #008000;">&lt;/</span>div<span style="color: #008000;">&gt;</span>
        <span style="color: #008000;">&lt;/</span>FooterTemplate<span style="color: #008000;">&gt;</span>
    <span style="color: #008000;">&lt;/</span>EPiServer<span style="color: #008000;">:</span>PageTree<span style="color: #008000;">&gt;</span>
<span style="color: #008000;">&lt;/</span>asp<span style="color: #008000;">:</span>Content<span style="color: #008000;">&gt;</span></pre></div></div>

<p>Notice ExpandAll=&#8221;true&#8221; property, this will expand all levels. The code-behind just gets the start position from the SitemapRoot property, if its not set it uses the start page as the start position.</p>

<div class="wp_syntax"><div class="code"><pre class="csharp" style="font-family:monospace;"><span style="color: #0600FF;">using</span> <span style="color: #008080;">EPiServer.Core</span><span style="color: #008000;">;</span>
<span style="color: #0600FF;">using</span> <span style="color: #008080;">Jungle.Templates.Jungle.PageTypes</span><span style="color: #008000;">;</span>
<span style="color: #0600FF;">using</span> <span style="color: #008080;">PageTypeBuilder.UI</span><span style="color: #008000;">;</span>
&nbsp;
<span style="color: #0600FF;">namespace</span> Jungle.<span style="color: #0000FF;">Templates</span>.<span style="color: #0000FF;">Jungle</span>.<span style="color: #0000FF;">Pages</span>
<span style="color: #000000;">&#123;</span>
    <span style="color: #0600FF;">public</span> <span style="color: #0600FF;">partial</span> <span style="color: #FF0000;">class</span> Sitemap <span style="color: #008000;">:</span> TemplatePage<span style="color: #008000;">&lt;</span>SitemapPage<span style="color: #008000;">&gt;</span>
    <span style="color: #000000;">&#123;</span>
        <span style="color: #0600FF;">protected</span> <span style="color: #0600FF;">override</span> <span style="color: #0600FF;">void</span> OnLoad<span style="color: #000000;">&#40;</span><span style="color: #000000;">System</span>.<span style="color: #0000FF;">EventArgs</span> e<span style="color: #000000;">&#41;</span>
        <span style="color: #000000;">&#123;</span>
            <span style="color: #0600FF;">base</span>.<span style="color: #0000FF;">OnLoad</span><span style="color: #000000;">&#40;</span>e<span style="color: #000000;">&#41;</span><span style="color: #008000;">;</span>
&nbsp;
            <span style="color: #0600FF;">this</span>.<span style="color: #0000FF;">SitemapTree</span>.<span style="color: #0000FF;">PageLink</span> <span style="color: #008000;">=</span> CurrentPage.<span style="color: #0000FF;">SitemapRoot</span> <span style="color: #008000;">??</span> PageReference.<span style="color: #0000FF;">StartPage</span><span style="color: #008000;">;</span>
            <span style="color: #0600FF;">this</span>.<span style="color: #0000FF;">SitemapTree</span>.<span style="color: #0000FF;">DataBind</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #008000;">;</span>
        <span style="color: #000000;">&#125;</span>
    <span style="color: #000000;">&#125;</span>
<span style="color: #000000;">&#125;</span></pre></div></div>

<p>Build, and go to edit mode, and create a new Sitemap page. Make sure that everything works. </p>
<p><img src="http://www.frederikvig.com/wp-content/uploads/jungle-site/part7/sitemap.png" alt="Sitemap page" /></p>
<p>This is a very common and standard sitemap page. Earlier the sitemap page was used by search engines for having a link to every page on the site. Fortunately Google, Microsoft, Yahoo! got together to create a <a href="http://www.sitemaps.org/">Sitemap XML standard</a> that the most popular search engines use. On <a href="https://www.coderesort.com/p/epicode/wiki/SearchEngineSitemaps">EPiCode we have the Search Engine Sitemap module</a> that creates an XML file according to the Sitemap XML standard for EPiServer sites. I recommend using it on all your sites for some free SEO boost.</p>
<p>After the introduction of the Search Engine Sitemap we have had some change on what the purpose and usage of the sitemap for a site would be. I&#8217;ve seen a lot of great sitemaps that do a much better job when it comes to usability than the traditional sitemap. One I like very much is <a href="http://www.wccnet.edu/services/">Washtenaw Community College service index</a>.</p>
<p>In this series I&#8217;ve tried keeping things simple, to give you a foundation that you can build and extend upon. This is especially true for the sitemap page type. I encourage you to extend it with your own code and functionality, making it even more usable.</p>
<h3>Cleaning up</h3>
<p>We&#8217;re using MainBody.ascx on most of our page templates. Some of the functionality we only need for Page.aspx. Lets create a new user control with the name ArticleMainBody.ascx, and copy paste everything from MainBody (except the first line), into ArticleMainBody.ascx. Update Page.aspx to use ArticleMainBody.ascx instead.</p>
<p>Lets remove most of the code from MainBody.ascx, we should have something like this left.</p>

<div class="wp_syntax"><div class="code"><pre class="csharp" style="font-family:monospace;"><span style="color: #008000;">&lt;%</span>@ Control Language<span style="color: #008000;">=</span><span style="color: #666666;">&quot;C#&quot;</span> AutoEventWireup<span style="color: #008000;">=</span><span style="color: #666666;">&quot;true&quot;</span> CodeBehind<span style="color: #008000;">=</span><span style="color: #666666;">&quot;MainBody.ascx.cs&quot;</span> Inherits<span style="color: #008000;">=</span><span style="color: #666666;">&quot;Jungle.Templates.Jungle.Units.MainBody&quot;</span> <span style="color: #008000;">%&gt;</span>
<span style="color: #008000;">&lt;</span>h2<span style="color: #008000;">&gt;&lt;%=</span> CurrentPage.<span style="color: #0000FF;">Heading</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span> <span style="color: #008000;">%&gt;&lt;/</span>h2<span style="color: #008000;">&gt;</span>
<span style="color: #008000;">&lt;</span>EPiServer<span style="color: #008000;">:</span>Property runat<span style="color: #008000;">=</span><span style="color: #666666;">&quot;server&quot;</span> PropertyName<span style="color: #008000;">=</span><span style="color: #666666;">&quot;MainBody&quot;</span> DisplayMissingMessage<span style="color: #008000;">=</span><span style="color: #666666;">&quot;false&quot;</span> EnableViewState<span style="color: #008000;">=</span><span style="color: #666666;">&quot;false&quot;</span> <span style="color: #008000;">/&gt;</span></pre></div></div>


<div class="wp_syntax"><div class="code"><pre class="csharp" style="font-family:monospace;"><span style="color: #0600FF;">using</span> <span style="color: #008080;">Jungle.Templates.Jungle.PageTypes</span><span style="color: #008000;">;</span>
<span style="color: #0600FF;">using</span> <span style="color: #008080;">PageTypeBuilder.UI</span><span style="color: #008000;">;</span>
&nbsp;
<span style="color: #0600FF;">namespace</span> Jungle.<span style="color: #0000FF;">Templates</span>.<span style="color: #0000FF;">Jungle</span>.<span style="color: #0000FF;">Units</span>
<span style="color: #000000;">&#123;</span>
    <span style="color: #0600FF;">public</span> <span style="color: #0600FF;">partial</span> <span style="color: #FF0000;">class</span> MainBody <span style="color: #008000;">:</span> UserControlBase<span style="color: #008000;">&lt;</span>BasePageData<span style="color: #008000;">&gt;</span>
    <span style="color: #000000;">&#123;</span>
    <span style="color: #000000;">&#125;</span>
<span style="color: #000000;">&#125;</span></pre></div></div>

<p>Build and make sure everything works.</p>
<h3>Refactoring</h3>
<p>Always try to improve and refactor your code along the way. I usually make it work, and then refactor my code. If you write the same code twice, try to take out the common code and place it somewhere where both can use it, either in a base class, a helper util class, extension method or something else. </p>
<p>I recommend checking out the <a href="31 Days of Refactoring">31 Days of Refactoring series</a> and the book <a href="http://www.wrox.com/WileyCDA/WroxTitle/Professional-Refactoring-in-C-ASP-NET.productCd-047043452X.html">Professional Refactoring in C# &#038; ASP.NET</a>, you also have the classic <a href="http://www.amazon.com/Refactoring-Improving-Design-Existing-Code/dp/0201485672">Refactoring: Improving the Design of Existing Code</a>.</p>
<p>In the last post in this series we&#8217;ll prepare for <a href="http://www.frederikvig.com/2009/12/part-8-preparing-for-launch-create-an-episerver-site-from-scratch/">launching the site</a>.<strong>Related Posts:</strong>
<ul class="similar-posts">
<li><a href="http://www.frederikvig.com/2009/12/part-5-creating-the-search-page-create-an-episerver-site-from-scratch/" rel="bookmark" title="December 16, 2009">Part 5: Creating the search page – Create an EPiServer site from scratch</a></li>
<li><a href="http://www.frederikvig.com/2009/12/part-6-creating-the-xform-page-create-an-episerver-site-from-scratch/" rel="bookmark" title="December 19, 2009">Part 6: Creating the XForm page – Create an EPiServer site from scratch</a></li>
<li><a href="http://www.frederikvig.com/2009/12/introduction-create-an-episerver-site-from-scratch/" rel="bookmark" title="December 1, 2009">Introduction &#8211; Create an EPiServer site from scratch</a></li>
<li><a href="http://www.frederikvig.com/2009/12/part-4-creating-the-standard-page-create-an-episerver-site-from-scratch/" rel="bookmark" title="December 13, 2009">Part 4: Creating the standard page – Create an EPiServer site from scratch</a></li>
<li><a href="http://www.frederikvig.com/2009/12/part-3-creating-the-start-page-create-an-episerver-site-from-scratch/" rel="bookmark" title="December 10, 2009">Part 3: Creating the start page – Create an EPiServer site from scratch</a></li>
</ul>
<p><!-- Similar Posts took 17.276 ms --></p>
<img src="http://feeds.feedburner.com/~r/frederikvig/~4/_F0DZStUE1g" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.frederikvig.com/2009/12/part-7-creating-the-sitemap-page-create-an-episerver-site-from-scratch/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		<feedburner:origLink>http://www.frederikvig.com/2009/12/part-7-creating-the-sitemap-page-create-an-episerver-site-from-scratch/</feedburner:origLink></item>
		<item>
		<title>Part 6: Creating the XForm page – Create an EPiServer site from scratch</title>
		<link>http://feedproxy.google.com/~r/frederikvig/~3/WKaj19Jzyv0/</link>
		<comments>http://www.frederikvig.com/2009/12/part-6-creating-the-xform-page-create-an-episerver-site-from-scratch/#comments</comments>
		<pubDate>Fri, 18 Dec 2009 23:01:38 +0000</pubDate>
		<dc:creator>Frederik Vig</dc:creator>
				<category><![CDATA[EPiServer]]></category>
		<category><![CDATA[EPiServer site]]></category>

		<guid isPermaLink="false">http://www.frederikvig.com/?p=509</guid>
		<description><![CDATA[The XForm page will help our editors collect data from their users. Editors can easily customize their forms the way that they want, and decide how to store the data (in a database, by email etc). 
Lets create a new page type.

using EPiServer.Core;
using EPiServer.XForms;
using PageTypeBuilder;
&#160;
namespace Jungle.Templates.Jungle.PageTypes
&#123;
    &#91;PageType&#40;
      [...]]]></description>
			<content:encoded><![CDATA[<p>The XForm page will help our editors collect data from their users. Editors can easily customize their forms the way that they want, and decide how to store the data (in a database, by email etc). </p>
<p>Lets create a new page type.</p>

<div class="wp_syntax"><div class="code"><pre class="csharp" style="font-family:monospace;"><span style="color: #0600FF;">using</span> <span style="color: #008080;">EPiServer.Core</span><span style="color: #008000;">;</span>
<span style="color: #0600FF;">using</span> <span style="color: #008080;">EPiServer.XForms</span><span style="color: #008000;">;</span>
<span style="color: #0600FF;">using</span> <span style="color: #008080;">PageTypeBuilder</span><span style="color: #008000;">;</span>
&nbsp;
<span style="color: #0600FF;">namespace</span> Jungle.<span style="color: #0000FF;">Templates</span>.<span style="color: #0000FF;">Jungle</span>.<span style="color: #0000FF;">PageTypes</span>
<span style="color: #000000;">&#123;</span>
    <span style="color: #000000;">&#91;</span>PageType<span style="color: #000000;">&#40;</span>
        Name <span style="color: #008000;">=</span> <span style="color: #666666;">&quot;[Jungle] XForm page&quot;</span>,
        Filename <span style="color: #008000;">=</span> <span style="color: #666666;">&quot;/Templates/Jungle/Pages/Xform.aspx&quot;</span>,
        SortOrder <span style="color: #008000;">=</span> <span style="color: #FF0000;">1020</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">&#93;</span>
    <span style="color: #0600FF;">public</span> <span style="color: #FF0000;">class</span> XFormPage <span style="color: #008000;">:</span> EditorialPage
    <span style="color: #000000;">&#123;</span>
        <span style="color: #000000;">&#91;</span>PageTypeProperty<span style="color: #000000;">&#40;</span>EditCaption <span style="color: #008000;">=</span> <span style="color: #666666;">&quot;XForm&quot;</span>, Searchable <span style="color: #008000;">=</span> <span style="color: #0600FF;">false</span>, Type <span style="color: #008000;">=</span> <span style="color: #008000;">typeof</span><span style="color: #000000;">&#40;</span>PropertyXForm<span style="color: #000000;">&#41;</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">&#93;</span>
        <span style="color: #0600FF;">public</span> <span style="color: #0600FF;">virtual</span> XForm XForm
        <span style="color: #000000;">&#123;</span>
            get<span style="color: #008000;">;</span>
            set<span style="color: #008000;">;</span>
        <span style="color: #000000;">&#125;</span>
    <span style="color: #000000;">&#125;</span>
<span style="color: #000000;">&#125;</span></pre></div></div>

<p>Like with StandardPage and SearchPage, we derive from EditorialPage, with the Heading and MainBody properties. We only have to add the XForm property for letting the editor choose which XForm she wishes to use.</p>
<p>Lets create the Xform.aspx page in Visual Studio, delete the default markup and add the master page.</p>

<div class="wp_syntax"><div class="code"><pre class="csharp" style="font-family:monospace;"><span style="color: #008000;">&lt;%</span>@ Page Language<span style="color: #008000;">=</span><span style="color: #666666;">&quot;C#&quot;</span> AutoEventWireup<span style="color: #008000;">=</span><span style="color: #666666;">&quot;true&quot;</span> CodeBehind<span style="color: #008000;">=</span><span style="color: #666666;">&quot;XForm.aspx.cs&quot;</span> Inherits<span style="color: #008000;">=</span><span style="color: #666666;">&quot;Jungle.Templates.Jungle.Pages.XForm&quot;</span> MasterPageFile<span style="color: #008000;">=</span><span style="color: #666666;">&quot;~/Templates/Jungle/MasterPages/Site.Master&quot;</span> <span style="color: #008000;">%&gt;</span></pre></div></div>


<div class="wp_syntax"><div class="code"><pre class="csharp" style="font-family:monospace;"><span style="color: #0600FF;">using</span> <span style="color: #008080;">Jungle.Templates.Jungle.PageTypes</span><span style="color: #008000;">;</span>
<span style="color: #0600FF;">using</span> <span style="color: #008080;">PageTypeBuilder.UI</span><span style="color: #008000;">;</span>
&nbsp;
<span style="color: #0600FF;">namespace</span> Jungle.<span style="color: #0000FF;">Templates</span>.<span style="color: #0000FF;">Jungle</span>.<span style="color: #0000FF;">Pages</span>
<span style="color: #000000;">&#123;</span>
    <span style="color: #0600FF;">public</span> <span style="color: #0600FF;">partial</span> <span style="color: #FF0000;">class</span> XForm <span style="color: #008000;">:</span> TemplatePage<span style="color: #008000;">&lt;</span>XFormPage<span style="color: #008000;">&gt;</span>
    <span style="color: #000000;">&#123;</span>
&nbsp;
    <span style="color: #000000;">&#125;</span>
<span style="color: #000000;">&#125;</span></pre></div></div>

<p>After you&#8217;ve done that create a new user control called XFormControl.</p>

<div class="wp_syntax"><div class="code"><pre class="csharp" style="font-family:monospace;"><span style="color: #008000;">&lt;%</span>@ Control Language<span style="color: #008000;">=</span><span style="color: #666666;">&quot;C#&quot;</span> AutoEventWireup<span style="color: #008000;">=</span><span style="color: #666666;">&quot;true&quot;</span> CodeBehind<span style="color: #008000;">=</span><span style="color: #666666;">&quot;XFormControl.ascx.cs&quot;</span> Inherits<span style="color: #008000;">=</span><span style="color: #666666;">&quot;Jungle.Templates.Jungle.Units.XFormControl&quot;</span> <span style="color: #008000;">%&gt;</span>
<span style="color: #008000;">&lt;</span>asp<span style="color: #008000;">:</span>Panel runat<span style="color: #008000;">=</span><span style="color: #666666;">&quot;server&quot;</span> CssClass<span style="color: #008000;">=</span><span style="color: #666666;">&quot;xForm&quot;</span><span style="color: #008000;">&gt;</span>
	<span style="color: #008000;">&lt;</span>XForms<span style="color: #008000;">:</span>XFormControl ID<span style="color: #008000;">=</span><span style="color: #666666;">&quot;FormControl&quot;</span> runat<span style="color: #008000;">=</span><span style="color: #666666;">&quot;server&quot;</span> ValidationGroup<span style="color: #008000;">=</span><span style="color: #666666;">&quot;XForm&quot;</span> <span style="color: #008000;">/&gt;</span>
<span style="color: #008000;">&lt;/</span>asp<span style="color: #008000;">:</span>Panel<span style="color: #008000;">&gt;</span></pre></div></div>

<p>The code-behind file has a public property for the XForm EPiServer property. This way we can easily reuse this user control in various page types. The other thing to note is how we create the form. We have the XFormControl, what we need to do is set its FormDefinition property to our form (which we need to create). The Form is a property that uses the XFormProperty property to get the form guid, which it then uses to create a new XForm instance.</p>

<div class="wp_syntax"><div class="code"><pre class="csharp" style="font-family:monospace;"><span style="color: #0600FF;">using</span> <span style="color: #008080;">System</span><span style="color: #008000;">;</span>
<span style="color: #0600FF;">using</span> <span style="color: #008080;">EPiServer.XForms</span><span style="color: #008000;">;</span>
<span style="color: #0600FF;">using</span> <span style="color: #008080;">Jungle.Templates.Jungle.PageTypes</span><span style="color: #008000;">;</span>
<span style="color: #0600FF;">using</span> <span style="color: #008080;">PageTypeBuilder.UI</span><span style="color: #008000;">;</span>
&nbsp;
<span style="color: #0600FF;">namespace</span> Jungle.<span style="color: #0000FF;">Templates</span>.<span style="color: #0000FF;">Jungle</span>.<span style="color: #0000FF;">Units</span>
<span style="color: #000000;">&#123;</span>
    <span style="color: #0600FF;">public</span> <span style="color: #0600FF;">partial</span> <span style="color: #FF0000;">class</span> XFormControl <span style="color: #008000;">:</span> UserControlBase<span style="color: #008000;">&lt;</span>BasePageData<span style="color: #008000;">&gt;</span>
    <span style="color: #000000;">&#123;</span>
        <span style="color: #0600FF;">private</span> XForm _form<span style="color: #008000;">;</span>
&nbsp;
        <span style="color: #0600FF;">protected</span> <span style="color: #0600FF;">override</span> <span style="color: #0600FF;">void</span> OnInit<span style="color: #000000;">&#40;</span>EventArgs e<span style="color: #000000;">&#41;</span>
        <span style="color: #000000;">&#123;</span>
            <span style="color: #0600FF;">base</span>.<span style="color: #0000FF;">OnInit</span><span style="color: #000000;">&#40;</span>e<span style="color: #000000;">&#41;</span><span style="color: #008000;">;</span>
&nbsp;
            <span style="color: #0600FF;">if</span> <span style="color: #000000;">&#40;</span><span style="color: #0600FF;">this</span>.<span style="color: #0000FF;">Form</span> <span style="color: #008000;">==</span> <span style="color: #0600FF;">null</span><span style="color: #000000;">&#41;</span>
            <span style="color: #000000;">&#123;</span>
                return<span style="color: #008000;">;</span>
            <span style="color: #000000;">&#125;</span>
&nbsp;
            FormControl.<span style="color: #0000FF;">FormDefinition</span> <span style="color: #008000;">=</span> <span style="color: #0600FF;">this</span>.<span style="color: #0000FF;">Form</span><span style="color: #008000;">;</span>
        <span style="color: #000000;">&#125;</span>
&nbsp;
        <span style="color: #0600FF;">public</span> XForm Form
        <span style="color: #000000;">&#123;</span>
            get
            <span style="color: #000000;">&#123;</span>
                <span style="color: #0600FF;">if</span> <span style="color: #000000;">&#40;</span>_form <span style="color: #008000;">==</span> <span style="color: #0600FF;">null</span><span style="color: #000000;">&#41;</span>
                <span style="color: #000000;">&#123;</span>
                    <span style="color: #FF0000;">string</span> formGuid <span style="color: #008000;">=</span> CurrentPage<span style="color: #000000;">&#91;</span><span style="color: #0600FF;">this</span>.<span style="color: #0000FF;">XFormProperty</span><span style="color: #000000;">&#93;</span> <span style="color: #0600FF;">as</span> string<span style="color: #008000;">;</span>
                    <span style="color: #0600FF;">if</span> <span style="color: #000000;">&#40;</span><span style="color: #008000;">!</span><span style="color: #FF0000;">string</span>.<span style="color: #0000FF;">IsNullOrEmpty</span><span style="color: #000000;">&#40;</span>formGuid<span style="color: #000000;">&#41;</span><span style="color: #000000;">&#41;</span>
                    <span style="color: #000000;">&#123;</span>
                        _form <span style="color: #008000;">=</span> XForm.<span style="color: #0000FF;">CreateInstance</span><span style="color: #000000;">&#40;</span><span style="color: #008000;">new</span> Guid<span style="color: #000000;">&#40;</span>formGuid<span style="color: #000000;">&#41;</span><span style="color: #000000;">&#41;</span><span style="color: #008000;">;</span>
                    <span style="color: #000000;">&#125;</span>
                <span style="color: #000000;">&#125;</span>
&nbsp;
                <span style="color: #0600FF;">return</span> _form<span style="color: #008000;">;</span>
            <span style="color: #000000;">&#125;</span>
            set
            <span style="color: #000000;">&#123;</span>
                _form <span style="color: #008000;">=</span> value<span style="color: #008000;">;</span>
            <span style="color: #000000;">&#125;</span>
        <span style="color: #000000;">&#125;</span>
&nbsp;
        <span style="color: #0600FF;">public</span> <span style="color: #FF0000;">string</span> XFormProperty
        <span style="color: #000000;">&#123;</span>
            get<span style="color: #008000;">;</span>
            set<span style="color: #008000;">;</span>
        <span style="color: #000000;">&#125;</span>
    <span style="color: #000000;">&#125;</span>
<span style="color: #000000;">&#125;</span></pre></div></div>

<p>For more information about the <a href="http://sdk.episerver.com/library/cms5/html/Properties_T_EPiServer_XForms_WebControls_XFormControl.htm">XFormControl see the SDK</a>.</p>
<p>Remember to add the usercontrol to XForm.aspx</p>

<div class="wp_syntax"><div class="code"><pre class="csharp" style="font-family:monospace;"><span style="color: #008000;">&lt;%</span>@ Page Language<span style="color: #008000;">=</span><span style="color: #666666;">&quot;C#&quot;</span> AutoEventWireup<span style="color: #008000;">=</span><span style="color: #666666;">&quot;true&quot;</span> CodeBehind<span style="color: #008000;">=</span><span style="color: #666666;">&quot;XForm.aspx.cs&quot;</span> Inherits<span style="color: #008000;">=</span><span style="color: #666666;">&quot;Jungle.Templates.Jungle.Pages.XForm&quot;</span> MasterPageFile<span style="color: #008000;">=</span><span style="color: #666666;">&quot;~/Templates/Jungle/MasterPages/Site.Master&quot;</span> <span style="color: #008000;">%&gt;</span>
<span style="color: #008000;">&lt;%</span>@ Register TagPrefix<span style="color: #008000;">=</span><span style="color: #666666;">&quot;Jungle&quot;</span> TagName<span style="color: #008000;">=</span><span style="color: #666666;">&quot;MainBody&quot;</span> Src<span style="color: #008000;">=</span><span style="color: #666666;">&quot;~/Templates/Jungle/Units/MainBody.ascx&quot;</span> <span style="color: #008000;">%&gt;</span>
<span style="color: #008000;">&lt;%</span>@ Register TagPrefix<span style="color: #008000;">=</span><span style="color: #666666;">&quot;Jungle&quot;</span> TagName<span style="color: #008000;">=</span><span style="color: #666666;">&quot;XFormControl&quot;</span> Src<span style="color: #008000;">=</span><span style="color: #666666;">&quot;~/Templates/Jungle/Units/XFormControl.ascx&quot;</span> <span style="color: #008000;">%&gt;</span>
&nbsp;
<span style="color: #008000;">&lt;</span>asp<span style="color: #008000;">:</span>Content ContentPlaceHolderID<span style="color: #008000;">=</span><span style="color: #666666;">&quot;MainContentRegion&quot;</span> runat<span style="color: #008000;">=</span><span style="color: #666666;">&quot;server&quot;</span><span style="color: #008000;">&gt;</span>
    <span style="color: #008000;">&lt;</span>Jungle<span style="color: #008000;">:</span>MainBody runat<span style="color: #008000;">=</span><span style="color: #666666;">&quot;server&quot;</span> <span style="color: #008000;">/&gt;</span>
&nbsp;
    <span style="color: #008000;">&lt;</span>Jungle<span style="color: #008000;">:</span>XFormControl
            runat<span style="color: #008000;">=</span><span style="color: #666666;">&quot;server&quot;</span> 
            XFormProperty<span style="color: #008000;">=</span><span style="color: #666666;">&quot;XForm&quot;</span> <span style="color: #008000;">/&gt;</span>
<span style="color: #008000;">&lt;/</span>asp<span style="color: #008000;">:</span>Content<span style="color: #008000;">&gt;</span></pre></div></div>

<p>Build and create a new XForm page with a test form.</p>
<p><img src="http://www.frederikvig.com/wp-content/uploads/jungle-site/part6/xform-contact-us.png" alt="" /></p>
<h3>Confirmation email</h3>
<p>So far so good, but we also want to send a confirmation email to the user when they&#8217;ve sent the form. Just a thank you for your feedback message, or something similar. I&#8217;ve written about this previously: <a href="http://www.frederikvig.com/2009/10/sending-confirmation-email-to-the-user-when-using-episerver-xforms/">Sending confirmation email to the user when using EPiServer XForms</a>. Read the blog post or download the code to see how I&#8217;ve implemented it.</p>
<p>One thing I&#8217;ve done, that differs from the original post, is that I&#8217;ve added a property that lets the editor edit the email text. For this I added a new property to [Jungle] XForm page:</p>

<div class="wp_syntax"><div class="code"><pre class="csharp" style="font-family:monospace;"><span style="color: #000000;">&#91;</span>PageTypeProperty<span style="color: #000000;">&#40;</span>
    EditCaption <span style="color: #008000;">=</span> <span style="color: #666666;">&quot;Confirmation email text&quot;</span>,
    Searchable <span style="color: #008000;">=</span> <span style="color: #0600FF;">true</span>,
    Type <span style="color: #008000;">=</span> <span style="color: #008000;">typeof</span><span style="color: #000000;">&#40;</span>PropertyXhtmlString<span style="color: #000000;">&#41;</span>,
    LongStringSettings <span style="color: #008000;">=</span> <span style="color: #000000;">&#40;</span>
	EditorToolOption.<span style="color: #0000FF;">All</span> <span style="color: #008000;">^</span>
	EditorToolOption.<span style="color: #0000FF;">Font</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">&#93;</span>
<span style="color: #0600FF;">public</span> <span style="color: #0600FF;">virtual</span> <span style="color: #FF0000;">string</span> ConfirmationEmailText
<span style="color: #000000;">&#123;</span>
    get<span style="color: #008000;">;</span>
    set<span style="color: #008000;">;</span>
<span style="color: #000000;">&#125;</span></pre></div></div>

<p><img src="http://www.frederikvig.com/wp-content/uploads/jungle-site/part6/confirmation-email.png" alt="" /></p>
<h3>Enter key</h3>
<p>A problem we&#8217;re facing is when users are filling out our form, and use the enter key. Instead of sending the form back to the server, they&#8217;re actually triggering the quick search button instead. The reason for this behavior is that ASP.NET web forms just uses one form for everything. Unfortunately there are no good fixes for this. One that I&#8217;ve used in the past is adding some JavaScript that detects if the enter key is pressed, and then triggers the first submit buttons click event. </p>
<p>The jQuery code for this:</p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;">$<span style="color: #009900;">&#40;</span><span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
    $<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'#id_matrix input'</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">keypress</span><span style="color: #009900;">&#40;</span><span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span>e<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
        <span style="color: #000066; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>e.<span style="color: #660066;">keyCode</span> <span style="color: #339933;">&amp;&amp;</span> e.<span style="color: #660066;">keyCode</span> <span style="color: #339933;">==</span> <span style="color: #CC0000;">13</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
            $<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'#id_matrix :submit:first'</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">click</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
            <span style="color: #000066; font-weight: bold;">return</span> <span style="color: #003366; font-weight: bold;">false</span><span style="color: #339933;">;</span>
        <span style="color: #009900;">&#125;</span> <span style="color: #000066; font-weight: bold;">else</span> <span style="color: #009900;">&#123;</span>
            <span style="color: #000066; font-weight: bold;">return</span> <span style="color: #003366; font-weight: bold;">true</span><span style="color: #339933;">;</span>
        <span style="color: #009900;">&#125;</span>
    <span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<p>You can of course modify the code to look for a button with the class &#8220;default&#8221; instead. But in my experience editors tend to forget this little detail, and they mostly only have one button anyway.</p>
<p>I&#8217;ve placed this code in an external JavaScript file, and added some code in XFormControl.ascx to add it.</p>

<div class="wp_syntax"><div class="code"><pre class="csharp" style="font-family:monospace;"><span style="color: #0600FF;">protected</span> <span style="color: #0600FF;">override</span> <span style="color: #0600FF;">void</span> OnInit<span style="color: #000000;">&#40;</span>EventArgs e<span style="color: #000000;">&#41;</span>
<span style="color: #000000;">&#123;</span>
    ...
&nbsp;
    <span style="color: #0600FF;">if</span> <span style="color: #000000;">&#40;</span><span style="color: #008000;">!</span>Page.<span style="color: #0000FF;">ClientScript</span>.<span style="color: #0000FF;">IsClientScriptIncludeRegistered</span><span style="color: #000000;">&#40;</span><span style="color: #666666;">&quot;Xform&quot;</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">&#41;</span>
    <span style="color: #000000;">&#123;</span>
	Page.<span style="color: #0000FF;">ClientScript</span>.<span style="color: #0000FF;">RegisterClientScriptInclude</span><span style="color: #000000;">&#40;</span><span style="color: #666666;">&quot;Xform&quot;</span>, Page.<span style="color: #0000FF;">ResolveUrl</span><span style="color: #000000;">&#40;</span><span style="color: #666666;">&quot;~/Templates/Jungle/Scripts/Xform.js&quot;</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">&#41;</span><span style="color: #008000;">;</span>
    <span style="color: #000000;">&#125;</span>
<span style="color: #000000;">&#125;</span></pre></div></div>

<p>Our users can now use the enter key! The drawback is that the submit button must be the first button, and that this only works when users have JavaScript enabled.</p>
<p>Great! We now have our form in place. Next up is <a href="http://www.frederikvig.com/2009/12/part-7-creating-the-sitemap-page-create-an-episerver-site-from-scratch/">Part 7: Creating the Sitemap page</a>.<strong>Related Posts:</strong>
<ul class="similar-posts">
<li><a href="http://www.frederikvig.com/2009/10/sending-confirmation-email-to-the-user-when-using-episerver-xforms/" rel="bookmark" title="October 17, 2009">Sending confirmation email to the user when using EPiServer XForms</a></li>
<li><a href="http://www.frederikvig.com/2009/12/part-5-creating-the-search-page-create-an-episerver-site-from-scratch/" rel="bookmark" title="December 16, 2009">Part 5: Creating the search page – Create an EPiServer site from scratch</a></li>
<li><a href="http://www.frederikvig.com/2009/12/part-7-creating-the-sitemap-page-create-an-episerver-site-from-scratch/" rel="bookmark" title="December 22, 2009">Part 7: Creating the Sitemap page – Create an EPiServer site from scratch</a></li>
<li><a href="http://www.frederikvig.com/2009/12/part-4-creating-the-standard-page-create-an-episerver-site-from-scratch/" rel="bookmark" title="December 13, 2009">Part 4: Creating the standard page – Create an EPiServer site from scratch</a></li>
<li><a href="http://www.frederikvig.com/2009/12/introduction-create-an-episerver-site-from-scratch/" rel="bookmark" title="December 1, 2009">Introduction &#8211; Create an EPiServer site from scratch</a></li>
</ul>
<p><!-- Similar Posts took 15.978 ms --></p>
<img src="http://feeds.feedburner.com/~r/frederikvig/~4/WKaj19Jzyv0" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.frederikvig.com/2009/12/part-6-creating-the-xform-page-create-an-episerver-site-from-scratch/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
		<feedburner:origLink>http://www.frederikvig.com/2009/12/part-6-creating-the-xform-page-create-an-episerver-site-from-scratch/</feedburner:origLink></item>
	</channel>
</rss><!-- WP Super Cache is installed but broken. The path to wp-cache-phase1.php in wp-content/advanced-cache.php must be fixed! -->
