Blog posts by Eric Pettersson
2016-04-25T22:43:01.0000000Z
/blogs/Eric-Pettersson/
Optimizely World
Change DisplayName (MetaData) for Image property for standard Image Dialog using EditorDescriptor
/blogs/Eric-Pettersson/Dates/2016/4/change-displayname-metadata-for-image-property-for-standard-image-dialog-using-editordescriptor/
2016-04-25T22:43:01.0000000Z
<p>This is a very simple way of changing the “Name” for a property when showed for the editors. We had a scenario were the editors would like to know the size of images when choosing what image to use for a specific image property.</p> <p>The property it self was just an ordinary ContentReference:</p><pre class="language-csharp"><code>[UIHint(UIHint.Image)]
<span class="kwrd">public</span> <span class="kwrd">virtual</span> ContentReference Eric { get; set; }
</code></pre>
<p>Nothing fancy with that just that we had validation on the pages saying that the image needed to be in a specific format like: 500px x 340px. This worked totally fine but the editor forgot the size and often picked the wrong size from the asset pane. To fix this we created a new EditorDescriptor inheriting from the ImageReferenceEditorDescriptor. By doing so we got the same dialog for selecting images but was able to change MetaData.</p>
<p> </p><pre class="language-csharp"><code>[EditorDescriptorRegistration(UIHint = <span class="str">"MyImage"</span>, TargetType = <span class="kwrd">typeof</span>(ContentReference))]
<span class="kwrd">public</span> <span class="kwrd">class</span> MyImageDescriptor : ImageReferenceEditorDescriptor
{
<span class="kwrd">public</span> <span class="kwrd">override</span> <span class="kwrd">void</span> ModifyMetadata(ExtendedMetadata metadata, IEnumerable<Attribute> attributes)
{
metadata.DisplayName = <span class="kwrd">string</span>.Format(<span class="str">"{0}<br/>{1}"</span>, metadata.DisplayName, <span class="str">"500 x 340px"</span>);
<span class="kwrd">base</span>.ModifyMetadata(metadata, attributes);
}
}</code></pre>
<style type="text/css">.csharpcode, .csharpcode pre
{
font-size: small;
color: black;
font-family: consolas, "Courier New", courier, monospace;
background-color: #ffffff;
/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt
{
background-color: #f4f4f4;
width: 100%;
margin: 0em;
}
.csharpcode .lnum { color: #606060; }
</style>
<p> </p>
<p>The new property would look like:</p><pre class="language-csharp"><code>[UIHint(<span class="str">"MyImage"</span>)]
<span class="kwrd">public</span> <span class="kwrd">virtual</span> ContentReference Eric { get; set; }
</code></pre>
<style type="text/css">.csharpcode, .csharpcode pre
{
font-size: small;
color: black;
font-family: consolas, "Courier New", courier, monospace;
background-color: #ffffff;
/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt
{
background-color: #f4f4f4;
width: 100%;
margin: 0em;
}
.csharpcode .lnum { color: #606060; }
</style>
<p>Doing this will result in a heading can contain more information then just the “Name” set in the model.</p>
<p><a href="/link/e6fa3e5735ff4476af9e6c6a50592af0.aspx"><img title="image" style="border-left-width: 0px; border-right-width: 0px; background-image: none; border-bottom-width: 0px; padding-top: 0px; padding-left: 0px; display: inline; padding-right: 0px; border-top-width: 0px" border="0" alt="image" src="/link/6d3c4e98ea4749faa010c9d7e61931a7.aspx" width="484" height="141" /></a></p>
<p>This is just an example, but what we did was that we extended this a little to handle different scenarios depending on the parent data. For instance if we used an image on an articlepage we had styleguides with one size and other sizes on newspage.</p>
<p>Lets say you have a validation attribute with information about the size of the image. You could then get the attribute by calling: metadata.Parent.Attributes and use that in your EditorDescriptor.</p>
Hide resizer.debug.ashx from your website.
/blogs/Eric-Pettersson/Dates/2016/4/hide-resizer-debug-ashx-from-your-website/
2016-04-22T13:29:50.0000000Z
<p>Many of us is using the popular <a title="http://imageresizing.net" href="http://imageresizing.net">http://imageresizing.net</a> library for manipulate or resizing images on our website. But with that plugin you will also get the resizer.debug.ashx. This little thingy is actually showing a lot of information about your website to the world.</p> <p>The page is actually part of the Diagnotics plugin and can be disabled by using the resizer section in web.config. If you can see ASP.NET error messages, you will also be able to get the diagnostics page. This ensures that the diagnostics page never exposes data to a host that doesn't already have access to detailed error messages, make sure you have configured the customError section correct in you web.config.</p> <p>Example of information exposed from one partner website:</p><pre class="language-csharp"><code>Environment information:
Running Microsoft-IIS/8.5 on Microsoft Windows NT 6.3.9600.0 and CLR 4.0.30319.42000
Trust level: Unrestricted
OS bitness: AMD64
Executing assembly: c:\windows\system32\inetsrv\w3wp.exe
IntegratedPipeline: True
Loaded assemblies:
mscorlib Assembly: 4.0.0.0 File: 4.6.1055.0 Info: 4.6.1055.0
System.Web Assembly: 4.0.0.0 File: 4.6.1069.1 Info: 4.6.1069.1
System Assembly: 4.0.0.0 File: 4.6.1055.0 Info: 4.6.1055.0
System.Core Assembly: 4.0.0.0 File: 4.6.1055.0 Info: 4.6.1055.0
System.Web.ApplicationServices Assembly: 4.0.0.0 File: 4.6.1069.1 Info: 4.6.1069.1
System.Configuration Assembly: 4.0.0.0 File: 4.6.1055.0 Info: 4.6.1055.0
System.Xml Assembly: 4.0.0.0 File: 4.6.1064.2 Info: 4.6.1064.2
System.Runtime.Caching Assembly: 4.0.0.0 File: 4.6.1055.0 Info: 4.6.1055.0
Microsoft.Build.Utilities.v4.0 Assembly: 4.0.0.0 File: 4.0.30319.33440 Info: 4.0.30319.33440
Microsoft.JScript Assembly: 10.0.0.0 File: 14.0.1055.0 Info: 14.0.1055.0</code></pre>
<style type="text/css">.csharpcode, .csharpcode pre
{
font-size: small;
color: black;
font-family: consolas, "Courier New", courier, monospace;
background-color: #ffffff;
/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt
{
background-color: #f4f4f4;
width: 100%;
margin: 0em;
}
.csharpcode .lnum { color: #606060; }
</style>
<p>I guess many of us does not care but I think it is a good idea to hide that information and we forget to set the right customErrors. Another way of removing information is to use a rewrite rule in your project like the one below instead of removing the plugin or rely on customerrors section.</p><pre class="language-csharp"><code> <span class="kwrd"><</span><span class="html">rule</span> <span class="attr">name</span><span class="kwrd">="ImageResizer"</span>
<span class="attr">patternSyntax</span><span class="kwrd">="Wildcard"</span>
<span class="attr">stopProcessing</span><span class="kwrd">="true"</span><span class="kwrd">></span>
<span class="kwrd"><</span><span class="html">match</span> <span class="attr">url</span><span class="kwrd">="*"</span> <span class="kwrd">/></span>
<span class="kwrd"><</span><span class="html">conditions</span><span class="kwrd">></span>
<span class="kwrd"><</span><span class="html">add</span> <span class="attr">input</span><span class="kwrd">="{URL}"</span>
<span class="attr">pattern</span><span class="kwrd">="/*.ashx"</span> <span class="kwrd">/></span>
<span class="kwrd"></</span><span class="html">conditions</span><span class="kwrd">></span>
<span class="kwrd"><</span><span class="html">action</span> <span class="attr">type</span><span class="kwrd">="CustomResponse"</span>
<span class="attr">statusCode</span><span class="kwrd">="404"</span>
<span class="attr">statusReason</span><span class="kwrd">="File or directory not found."</span>
<span class="attr">statusDescription</span><span class="kwrd">="The resource you are looking for might have been removed, had its name changed, or is temporarily unavailable."</span> <span class="kwrd">/></span>
<span class="kwrd"></</span><span class="html">rule</span><span class="kwrd">></span></code></pre>
<style type="text/css">.csharpcode, .csharpcode pre
{
font-size: small;
color: black;
font-family: consolas, "Courier New", courier, monospace;
background-color: #ffffff;
/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt
{
background-color: #f4f4f4;
width: 100%;
margin: 0em;
}
.csharpcode .lnum { color: #606060; }
</style>
Fixing the WebSocket Protocol Support issue when upgrading to EPiServer UI 9.4.0
/blogs/Eric-Pettersson/Dates/2016/2/fixing-the-websocket-protocol-support-issue-when-upgrading-to-episerver-ui-9-4-0/
2016-02-23T22:18:50.0000000Z
<p>I experienced a small but annoying error today when I installed a brand new CMS website with latest updates and also upgraded a website to the latest version of episerver cms. </p> <p>The error occurred inside edit mode but did not show in Internet Explorer. The error message in episerver was:</p> <p>“A real-time connection could not be established with the server. This may be caused by incorrect configuration. Please see the User interface section in the user guide for further information.”</p> <p>So something must have happened in the latest release since I did not have this message last week. Firebug did the trick and help with finding the error:</p> <p><em><strong>Firefox can't establish a connection to the server at wss://yoursite.com/EPiServer/Shell/socket/endpoint/.</strong></em><br /><em><strong>socket = new WebSocket(this._path);</strong></em></p> <p> </p> <p>Fixing the problem is to install websocket support like below.</p> <h2>For Windows Server 2012</h2> <p><a href="/link/67e9117db06a42ee8c0a79059818fe2e.aspx"><img title="server_thumb3" style="border-top: 0px; border-right: 0px; background-image: none; border-bottom: 0px; padding-top: 0px; padding-left: 0px; margin: 0px; border-left: 0px; display: inline; padding-right: 0px" border="0" alt="server_thumb3" src="/link/50f160b2779549dfb5dfd8b6cc5456c9.aspx" width="684" height="684" /></a></p> <p> </p> <h2>And for Windows 8 and above:</h2> <p><a href="/link/3444ca2feede42688cc2e192afe82517.aspx"><img title="win8_thumb3" style="border-top: 0px; border-right: 0px; background-image: none; border-bottom: 0px; padding-top: 0px; padding-left: 0px; border-left: 0px; display: inline; padding-right: 0px" border="0" alt="win8_thumb3" src="/link/b333372c88904c18b92a297a87f3bc89.aspx" width="425" height="551" /></a></p> <p> </p> <p><strong>Update (Thanks Stephan):</strong></p> <p>If you are using an older system IIS 7.5 or below you will need to disable WebSockets to get rid of the error message.</p><pre class="language-csharp"><code><span class="kwrd"><</span><span class="html">add</span> <span class="attr">key</span><span class="kwrd">="Epi.WebSockets.Enabled"</span> <span class="attr">value</span><span class="kwrd">="false"</span> <span class="kwrd">/></span></code></pre>
<style type="text/css">.csharpcode, .csharpcode pre
{
font-size: small;
color: black;
font-family: consolas, "Courier New", courier, monospace;
background-color: #ffffff;
/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt
{
background-color: #f4f4f4;
width: 100%;
margin: 0em;
}
.csharpcode .lnum { color: #606060; }
</style>
<p>You can find more information at: </p>
<p><a title="http://world.episerver.com/documentation/Items/Developers-Guide/Episerver-CMS/9/User-interface/websocket-support/" href="/link/16b754e4f7a84c81b279a15ca7f09fe7.aspx">http://world.episerver.com/documentation/Items/Developers-Guide/Episerver-CMS/9/User-interface/websocket-support/</a></p>
<p><a title="http://www.iis.net/learn/get-started/whats-new-in-iis-8/iis-80-websocket-protocol-support" href="http://www.iis.net/learn/get-started/whats-new-in-iis-8/iis-80-websocket-protocol-support">http://www.iis.net/learn/get-started/whats-new-in-iis-8/iis-80-websocket-protocol-support</a></p>
Simple robots.txt built with asp.net mvc
/blogs/Eric-Pettersson/Dates/2015/4/simple-robots-txt-build-with-asp-net-mvc/
2015-04-27T08:25:53.0000000Z
<p>The other day there was a question about serving static files from episerver, like a robots.txt. Since most editor like to be able to update the robots.txt them self many of us has build solutions for that. There are also some packages in the nuget feed from EPiServer that will help you do just that. </p> <p>But if you are like me, I do not like to have pre-compiled solutions from other companies in my project, some are better then others but still I like to be able to change most of my code in a project. Of course you can download the source code in many of those packages but some times they tend to do a bit more then you might expected as well.</p> <p> </p> <p>In this case I just would like to serve a robots.txt if it is requested by a search engine for instance.</p> <h2>Solution</h2> <p>First I create the robots.txt controller. Since we are working with EPiServer CMS I have added a textarea on the startpage type and therefore editors are able to change the content of the file.</p> <p> </p> <div class="csharpcode"> <pre class="language-csharp"><code><span class="lnum"> 1: </span> <span class="kwrd">public</span> <span class="kwrd">class</span> RobotsTxtController : Controller</code></pre>
<pre class="language-csharp"><code><span class="lnum"> 2: </span> {</code></pre>
<pre class="language-csharp"><code><span class="lnum"> 3: </span> <span class="kwrd">private</span> Injected<IContentLoader> ContentLoader { get; set; }</code></pre>
<pre class="language-csharp"><code><span class="lnum"> 4: </span> <style type="text/css">.csharpcode, .csharpcode pre
{
font-size: small;
color: black;
font-family: consolas, "Courier New", courier, monospace;
background-color: #ffffff;
/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt
{
background-color: #f4f4f4;
width: 100%;
margin: 0em;
}
.csharpcode .lnum { color: #606060; }
</style></code></pre>
<pre class="language-csharp"><code><span class="lnum"> 5: </span> [ContentOutputCache]</code></pre>
<pre class="language-csharp"><code><span class="lnum"> 6: </span> <span class="kwrd">public</span> ActionResult Index()</code></pre>
<pre class="language-csharp"><code><span class="lnum"> 7: </span> {</code></pre>
<pre class="language-csharp"><code><span class="lnum"> 8: </span> var startPage = ContentLoader.Service.Get<StartPage>(ContentReference.StartPage);</code></pre>
<pre class="language-csharp"><code><span class="lnum"> 9: </span> </code></pre>
<pre class="language-csharp"><code><span class="lnum"> 10: </span> <span class="kwrd">string</span> content = startPage.RobotsTxtContent;</code></pre>
<pre class="language-csharp"><code><span class="lnum"> 11: </span> <span class="kwrd">return</span> Content(content, <span class="str">"text/plain"</span>);</code></pre>
<pre class="language-csharp"><code><span class="lnum"> 12: </span> }</code></pre>
<pre class="language-csharp"><code><span class="lnum"> 13: </span> }</code></pre>
</div>
<style type="text/css">
.csharpcode, .csharpcode pre
{
font-size: small;
color: black;
font-family: consolas, "Courier New", courier, monospace;
background-color: #ffffff;
/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt
{
background-color: #f4f4f4;
width: 100%;
margin: 0em;
}
.csharpcode .lnum { color: #606060; }</style>
<p> </p>
<p>Nesx step is to create an initialization module were we map a route to our robots.txt file. </p>
<p> </p>
<div class="csharpcode">
<pre class="language-csharp"><code><span class="lnum"> 1: </span>[InitializableModule]</code></pre>
<pre class="language-csharp"><code><span class="lnum"> 2: </span> [ModuleDependency(<span class="kwrd">typeof</span>(EPiServer.Web.InitializationModule))]</code></pre>
<pre class="language-csharp"><code><span class="lnum"> 3: </span> <span class="kwrd">public</span> <span class="kwrd">class</span> RenderingInitialization : IInitializableModule</code></pre>
<pre class="language-csharp"><code><span class="lnum"> 4: </span> {</code></pre>
<pre class="language-csharp"><code><span class="lnum"> 5: </span> <span class="kwrd">public</span> <span class="kwrd">void</span> Initialize(InitializationEngine context)</code></pre>
<pre class="language-csharp"><code><span class="lnum"> 6: </span> {</code></pre>
<pre class="language-csharp"><code><span class="lnum"> 7: </span> </code></pre>
<pre class="language-csharp"><code><span class="lnum"> 8: </span> <span class="rem">//Maps route for robots.txt</span></code></pre>
<pre class="language-csharp"><code><span class="lnum"> 9: </span> RouteTable.Routes.MapRoute(<span class="str">"RobotsTxtRoute"</span>, <span class="str">"robots.txt"</span>, <span class="kwrd">new</span> { controller = <span class="str">"RobotsTxt"</span>, action = <span class="str">"Index"</span> });</code></pre>
<pre class="language-csharp"><code><span class="lnum"> 10: </span> }</code></pre>
<pre class="language-csharp"><code><span class="lnum"> 11: </span> </code></pre>
<pre class="language-csharp"><code><span class="lnum"> 12: </span> </code></pre>
<pre class="language-csharp"><code><span class="lnum"> 13: </span> <span class="kwrd">public</span> <span class="kwrd">void</span> Preload(<span class="kwrd">string</span>[] parameters) { }</code></pre>
<pre class="language-csharp"><code><span class="lnum"> 14: </span> </code></pre>
<pre class="language-csharp"><code><span class="lnum"> 15: </span> <span class="kwrd">public</span> <span class="kwrd">void</span> Uninitialize(InitializationEngine context)</code></pre>
<pre class="language-csharp"><code><span class="lnum"> 16: </span> {</code></pre>
<pre class="language-csharp"><code><span class="lnum"> 17: </span> <span class="rem">//Add uninitialization logic</span></code></pre>
<pre class="language-csharp"><code><span class="lnum"> 18: </span> </code></pre>
<pre class="language-csharp"><code><span class="lnum"> 19: </span> }</code></pre>
<pre class="language-csharp"><code><span class="lnum"> 20: </span> }</code></pre>
</div>
<style type="text/css">
.csharpcode, .csharpcode pre
{
font-size: small;
color: black;
font-family: consolas, "Courier New", courier, monospace;
background-color: #ffffff;
/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt
{
background-color: #f4f4f4;
width: 100%;
margin: 0em;
}
.csharpcode .lnum { color: #606060; }</style>
<p> </p>
<p>And finally we add the property to our startpage model</p>
<pre class="language-csharp"><code> [UIHint(UIHint.Textarea)]
[Display(Name = <span class="str">"Robots.txt"</span>, Order = 90, GroupName = Global.GroupNames.SiteSettings)]
<span class="kwrd">public</span> <span class="kwrd">virtual</span> <span class="kwrd">string</span> RobotsTxtContent { get; set; }</code></pre>
<style type="text/css">
.csharpcode, .csharpcode pre
{
font-size: small;
color: black;
font-family: consolas, "Courier New", courier, monospace;
background-color: #ffffff;
/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt
{
background-color: #f4f4f4;
width: 100%;
margin: 0em;
}
.csharpcode .lnum { color: #606060; }</style>
Installing the nuget for EPiServer GoogleAnalytics and virtual Roles
/blogs/Eric-Pettersson/Dates/2015/4/installing-the-nuget-for-episerver-googleanalytics-and-virtual-roles/
2015-04-20T11:21:29.0000000Z
<p>This is a short post and a reminder since I had trouble with installing the Google Analytics addon from EPiServer the other day.</p> <p>They are looking for GoogleAnalyticsAdministrators that is supposed to be mapped to a specific group. But if you have not setup the website with these roles it will fail and the website will not start. Instead you will get the following error.</p> <pre class="language-csharp"><code>Serverfel i tillämpningsprogrammet /.
The list of roles <span class="kwrd">for</span> <span class="kwrd">virtual</span> role <span class="str">'GoogleAnalyticsAdministrators'</span> <span class="kwrd">is</span> not valid
Parameternamn: config
Beskrivning: Ett undantag som inte kunde hanteras uppstod när den aktuella webbegäran kördes. Mer information om felet och var i koden det uppstod finns i stackspårningen.
Undantagsinformation: System.ArgumentException: The list of roles <span class="kwrd">for</span> <span class="kwrd">virtual</span> role <span class="str">'GoogleAnalyticsAdministrators'</span> <span class="kwrd">is</span> not valid
Parameternamn: config
Källfel:
Ett undantag som inte hanteras genererades vid körningen av den aktuella webbegäran. Information om undantagets ursprung och plats kan identifieras med undantagsstackspårningen nedan.Stackspårning:
[ArgumentException: The list of roles <span class="kwrd">for</span> <span class="kwrd">virtual</span> role <span class="str">'GoogleAnalyticsAdministrators'</span> <span class="kwrd">is</span> not valid
Parameternamn: config]
EPiServer.Security.MappedRole.Initialize(String name, NameValueCollection config) +545
EPiServer.GoogleAnalytics.InitializationModule.EnsureMappedRoleExists(VirtualRoleRepository`1 vrReposistory, String name, String roles) +153
EPiServer.GoogleAnalytics.InitializationModule.InitializeVirtualRoles() +558
EPiServer.GoogleAnalytics.InitializationModule.application_PostAuthenticateRequest(Object sender, EventArgs e) +5
System.Web.SyncEventExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() +136
System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) +69
Versionsinformation: Microsoft .NET Framework-version:4.0.30319; ASP.NET-version:4.0.30319.34212 </code></pre>
<p><style type="text/css">
.csharpcode, .csharpcode pre
{
font-size: small;
color: black;
font-family: consolas, "Courier New", courier, monospace;
background-color: #ffffff;
/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt
{
background-color: #f4f4f4;
width: 100%;
margin: 0em;
}
.csharpcode .lnum { color: #606060; }</style></p>
<h3>Solution</h3>
<p>Before you install you setup the groups WebEditors and WebAdmins in the CMS – Admin interface. Or  you can add a virtualroles mapping in web.config for the specific groups.</p>
<p> </p>
<pre class="language-csharp"><code> <virtualRoles addClaims=<span class="str">"true"</span>>
<providers>
<add name=<span class="str">"Administrators"</span> type=<span class="str">"EPiServer.Security.WindowsAdministratorsRole, EPiServer.Framework"</span> />
<add name=<span class="str">"Everyone"</span> type=<span class="str">"EPiServer.Security.EveryoneRole, EPiServer.Framework"</span> />
<add name=<span class="str">"Authenticated"</span> type=<span class="str">"EPiServer.Security.AuthenticatedRole, EPiServer.Framework"</span> />
<add name=<span class="str">"Anonymous"</span> type=<span class="str">"EPiServer.Security.AnonymousRole, EPiServer.Framework"</span> />
<add name=<span class="str">"CmsAdmins"</span> type=<span class="str">"EPiServer.Security.MappedRole, EPiServer.Framework"</span> roles=<span class="str">"WebAdmins, Administrators"</span> mode=<span class="str">"Any"</span> />
<add name=<span class="str">"CmsEditors"</span> type=<span class="str">"EPiServer.Security.MappedRole, EPiServer.Framework"</span> roles=<span class="str">"WebEditors"</span> mode=<span class="str">"Any"</span> />
<add name=<span class="str">"GoogleAnalyticsAdministrators"</span> type=<span class="str">"EPiServer.Security.MappedRole, EPiServer.Framework"</span> roles=<span class="str">"Administrators"</span> mode=<span class="str">"Any"</span> />
<add name=<span class="str">"Creator"</span> type=<span class="str">"EPiServer.Security.CreatorRole, EPiServer"</span> />
<add name=<span class="str">"PackagingAdmins"</span> type=<span class="str">"EPiServer.Security.MappedRole, EPiServer.Framework"</span> roles=<span class="str">"WebAdmins, Administrators"</span> mode=<span class="str">"Any"</span> />
</providers>
</virtualRoles></code></pre>
<style type="text/css">
.csharpcode, .csharpcode pre
{
font-size: small;
color: black;
font-family: consolas, "Courier New", courier, monospace;
background-color: #ffffff;
/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt
{
background-color: #f4f4f4;
width: 100%;
margin: 0em;
}
.csharpcode .lnum { color: #606060; }</style>
A reminder, things you also need when installing Google Analytics plugin for EPiServer and using ASP.Net MVC
/blogs/Eric-Pettersson/2015/2/a-reminder-things-you-also-need-when-installing-google-analytics-plugin-for-episerver-and-using-asp-net-mvc/
2015-02-04T13:30:56.0000000Z
<p>There are probably some documentation regarding this on EPiServer World but I had some trouble finding the information needed. Installation of the Add-On for Google analytics is really easy but to make everything work we also need to put some code in your views, not only install the add-on</p> <h2>There are two ways of make Google Analytics track your visitors:</h2> <p><strong>Update:</strong></p> <ul> <li>Use RequiredClientResources (Recommended)</li> </ul> <div class="csharpcode"> <pre class="language-csharp"><code><span class="lnum"> 1: </span>@Html.RequiredClientResources(RenderingTags.Header)</code></pre>
<pre class="language-csharp"><code><span class="lnum"> 2: </span> </code></pre>
<pre class="language-csharp"><code><span class="lnum"> 3: </span>@Html.RequiredClientResources(RenderingTags.Footer) </code></pre>
</div>
<style type="text/css">
.csharpcode, .csharpcode pre
{
font-size: small;
color: black;
font-family: consolas, "Courier New", courier, monospace;
background-color: #ffffff;
/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt
{
background-color: #f4f4f4;
width: 100%;
margin: 0em;
}
.csharpcode .lnum { color: #606060; }</style>
<ul>
<li>Or use AnalyticsTrackingScript helper if you are not using above already in your _Layout.cshtml</li>
</ul>
<div class="csharpcode">
<pre class="language-csharp"><code><span class="lnum"> 1: </span>@Html.AnalyticsTrackingScript(Model.CurrentPage)</code></pre>
</div>
<style type="text/css">
.csharpcode, .csharpcode pre
{
font-size: small;
color: black;
font-family: consolas, "Courier New", courier, monospace;
background-color: #ffffff;
/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt
{
background-color: #f4f4f4;
width: 100%;
margin: 0em;
}
.csharpcode .lnum { color: #606060; }</style><style type="text/css">
.csharpcode, .csharpcode pre
{
font-size: small;
color: black;
font-family: consolas, "Courier New", courier, monospace;
background-color: #ffffff;
/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt
{
background-color: #f4f4f4;
width: 100%;
margin: 0em;
}
.csharpcode .lnum { color: #606060; }</style>
<p> </p>
<p>And that’s it.</p>
<p>Happy tracking</p>
Problem with web.config after upgrade between MVC 4 and MVC 5, 5.2.0.0 and 3.0.0.0 and missing intellisense in Visual Studio.
/blogs/Eric-Pettersson/Dates/2014/10/problem-with-web-config-after-upgrade-between-mvc-4-and-mvc-5-5-2-0-0-and-3-0-0-0-and-missing-intellisense-in-visual-studio/
2014-10-16T18:48:19.0000000Z
<p>This one will be a short blog post but I somehow a bit related to my last post about version of MVC and the 404 handlar from BVN Networks.</p>
<p>I recently created a new project and updated all nuget packages to the latest version of both EPiServer and Nugets from Microsoft.</p>
<p>After the upgrade I could not get the site to start and I got a strange error message. I also had problem with intellisense and none of the old ways of fixing the intellisense problem seemed to help.</p>
<h2>The first error:</h2>
<pre class="language-csharp"><code>[A]System.Web.WebPages.Razor.Configuration.HostSection cannot be cast to
[B]System.Web.WebPages.Razor.Configuration.HostSection.
Type A originates from <span class="str">'System.Web.WebPages.Razor, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35'</span> <span class="kwrd">in</span> the context <span class="str">'Default'</span> at location <span class="str">'C:\WINDOWS\Microsoft.Net\assembly\GAC_MSIL\System.Web.WebPages.Razor\v4.0_2.0.0.0__31bf3856ad364e35\System.Web.WebPages.Razor.dll'</span>.
Type B originates from <span class="str">'System.Web.WebPages.Razor, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35'</span> <span class="kwrd">in</span> the context <span class="str">'Default'</span> at location <span class="str">'C:\Users\MyName\AppData\Local\Temp\Temporary ASP.NET Files\root\63e7ff36\a1cb775d\assembly\dl3\8f568c18\9b7ddacf_d04dcf01\System.Web.WebPages.Razor.dll'</span>.</code></pre>
<style type="text/css"><!--
.csharpcode, .csharpcode pre
{
font-size: small;
color: black;
font-family: consolas, "Courier New", courier, monospace;
background-color: #ffffff;
/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt
{
background-color: #f4f4f4;
width: 100%;
margin: 0em;
}
.csharpcode .lnum { color: #606060; }
--></style>
<p> </p>
<p>This is casued by wrong versionnumbers in your config-files. This is easy to fix.</p>
<h2>The fix:</h2>
<p> </p>
<pre class="language-csharp"><code> <span class="kwrd"><</span><span class="html">dependentAssembly</span><span class="kwrd">></span>
<span class="kwrd"><</span><span class="html">assemblyIdentity</span> <span class="attr">name</span><span class="kwrd">="System.Web.Mvc"</span>
<span class="attr">publicKeyToken</span><span class="kwrd">="31bf3856ad364e35"</span> <span class="kwrd">/></span>
<span class="kwrd"><</span><span class="html">bindingRedirect</span> <span class="attr">oldVersion</span><span class="kwrd">="0.0.0.0-5.2.2.0"</span>
<span class="attr">newVersion</span><span class="kwrd">="5.2.2.0"</span> <span class="kwrd">/></span>
<span class="kwrd"></</span><span class="html">dependentAssembly</span><span class="kwrd">></span></code></pre>
<style type="text/css"><!--
.csharpcode, .csharpcode pre
{
font-size: small;
color: black;
font-family: consolas, "Courier New", courier, monospace;
background-color: #ffffff;
/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt
{
background-color: #f4f4f4;
width: 100%;
margin: 0em;
}
.csharpcode .lnum { color: #606060; }
--></style>
<pre class="language-csharp"><code><span class="kwrd"><</span><span class="html">appSettings</span><span class="kwrd">></span>
<span class="kwrd"><</span><span class="html">add</span> <span class="attr">key</span><span class="kwrd">="webpages:Version"</span>
<span class="attr">value</span><span class="kwrd">="3.0.0.0"</span> <span class="kwrd">/></span>
...
<span class="kwrd"></</span><span class="html">appSettings</span><span class="kwrd">></span></code></pre>
<style type="text/css"><!--
.csharpcode, .csharpcode pre
{
font-size: small;
color: black;
font-family: consolas, "Courier New", courier, monospace;
background-color: #ffffff;
/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt
{
background-color: #f4f4f4;
width: 100%;
margin: 0em;
}
.csharpcode .lnum { color: #606060; }
--></style>
<p> </p>
<h2>The intellisense error for razorpages:</h2>
<p>To fix the intellisense problem we need to update another web.config. This is located in the views-folder. If you look into this folder you will find out that you will need to fix other assembly versions as well:</p>
<p>In a view you will get the this problem with intellisens for helpers and types pages. Also the @model declaration is not working.</p>
<p><img alt="" src="/link/69ea28e40e6246b29ef88f4bd3d82d22.aspx" height="152" width="444" /> </p>
<p>You need to change the following to target 3.0.0.0 as below</p>
<pre class="language-csharp"><code> <span class="kwrd"><</span><span class="html">sectionGroup</span> <span class="attr">name</span><span class="kwrd">="system.web.webPages.razor"</span>
<span class="attr">type</span><span class="kwrd">="System.Web.WebPages.Razor.Configuration.RazorWebSectionGroup, System.Web.WebPages.Razor, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"</span><span class="kwrd">></span>
<span class="kwrd"><</span><span class="html">section</span> <span class="attr">name</span><span class="kwrd">="host"</span>
<span class="attr">type</span><span class="kwrd">="System.Web.WebPages.Razor.Configuration.HostSection, System.Web.WebPages.Razor, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"</span>
<span class="attr">requirePermission</span><span class="kwrd">="false"</span> <span class="kwrd">/></span>
<span class="kwrd"><</span><span class="html">section</span> <span class="attr">name</span><span class="kwrd">="pages"</span>
<span class="attr">type</span><span class="kwrd">="System.Web.WebPages.Razor.Configuration.RazorPagesSection, System.Web.WebPages.Razor, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"</span>
<span class="attr">requirePermission</span><span class="kwrd">="false"</span> <span class="kwrd">/></span>
<span class="kwrd"></</span><span class="html">sectionGroup</span><span class="kwrd">></span></code></pre>
<style type="text/css"><!--
.csharpcode, .csharpcode pre
{
font-size: small;
color: black;
font-family: consolas, "Courier New", courier, monospace;
background-color: #ffffff;
/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt
{
background-color: #f4f4f4;
width: 100%;
margin: 0em;
}
.csharpcode .lnum { color: #606060; }
--></style>
<p> </p>
<p>To get the intellisense to work properly you also need to change to the latest version as below:</p>
<pre class="language-csharp"><code> <span class="kwrd"><</span><span class="html">host</span> <span class="attr">factoryType</span><span class="kwrd">="System.Web.Mvc.MvcWebRazorHostFactory, System.Web.Mvc, Version=5.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"</span> <span class="kwrd">/></span>
</code></pre>
<style type="text/css"><!--
.csharpcode, .csharpcode pre
{
font-size: small;
color: black;
font-family: consolas, "Courier New", courier, monospace;
background-color: #ffffff;
/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt
{
background-color: #f4f4f4;
width: 100%;
margin: 0em;
}
.csharpcode .lnum { color: #606060; }
--></style>
<p>If you need further assistance you can follow this post about upgrade an mvc project.</p>
<p><strong>Update:</strong></p>
<p>The old url did not work</p>
<p>References: <a title="how-to-upgrade-an-aspnet-mvc-4-and-web-api-project-to-aspnet-mvc-5-and-web-api-2" href="http://www.asp.net/mvc/overview/releases/how-to-upgrade-an-aspnet-mvc-4-and-web-api-project-to-aspnet-mvc-5-and-web-api-2">http://www.asp.net/mvc/overview/releases/how-to-upgrade-an-aspnet-mvc-4-and-web-api-project-to-aspnet-mvc-5-and-web-api-2</a></p>
500 Internal Server Error in the gadget, 404 handler for CMS 7, from BV Network (MVC)
/blogs/Eric-Pettersson/Dates/2014/8/500-Internal-Server-Error-in-the-gadget-404-handler-for-CMS-7-from-BV-Network-MVC/
2014-08-26T13:26:30.0000000Z
<p>Installing the common 404 handler that is available via nuget.episerver.com or via the project website, <a title="http://world.episerver.com/Blogs/Per-Magne-Skuseth/Dates/2013/2/404-handler-for-EPiServer-7/" href="http://world.episerver.com/Blogs/Per-Magne-Skuseth/Dates/2013/2/404-handler-for-EPiServer-7/">http://world.episerver.com/Blogs/Per-Magne-Skuseth/Dates/2013/2/404-handler-for-EPiServer-7/</a> <a title="https://www.coderesort.com/p/epicode/wiki/404Handler#Custom404HandlerforEPiServer7" href="https://www.coderesort.com/p/epicode/wiki/404Handler#Custom404HandlerforEPiServer7">https://www.coderesort.com/p/epicode/wiki/404Handler#Custom404HandlerforEPiServer7</a> should be easy but sometimes things might be more troublesome than you think.</p> <p>So this blog post is going to be short but describing the error and my solution <img class="wlEmoticon wlEmoticon-smile" style="border-top-style: none; border-bottom-style: none; border-right-style: none; border-left-style: none" alt="Ler" src="/link/009c0146ba9d44c8be0b6e755a1eba13.png" /></p> <p> </p> <h2>The Error</h2> <p>Everything is installed without any problem but when trying to use the gadget I got an error message.</p> <p>When trying to add the gadget to the dashboard I got this error: <strong>Sorry, an error occurred</strong>. That didn’t tell us much but since most of us are using modern browsers, hitting the f12 button will fire the developer tools. Looking in the console window I found out that I had a 500 Internal Server Error:</p> <p><a href="/link/b2acd30739b64e3b8c15ff307308529a.png"><img title="error1" style="border-top: 0px; border-right: 0px; background-image: none; border-bottom: 0px; padding-top: 0px; padding-left: 0px; border-left: 0px; display: inline; padding-right: 0px" border="0" alt="error1" src="/link/85e8840996cb44e5987b8b2c3d618882.png" width="1225" height="113" /></a></p> <p>The actual error message was this:</p> <pre class="language-csharp"><code>Server Error in '/' Application.
________________________________________
Configuration Error
Description: An error occurred during the processing of a configuration file required to service this request. Please review the specific error details below and modify your configuration file appropriately.
Parser Error Message: Could not load file or assembly 'System.Web.Mvc, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)
Source Error:
Line 13: controller or action.
Line 14: --<span class="kwrd">></span>
Line 15: <span class="kwrd"><</span><span class="html">pages</span> <span class="attr">validateRequest</span><span class="kwrd">="false"</span> <span class="attr">pageParserFilterType</span><span class="kwrd">="System.Web.Mvc.ViewTypeParserFilter, System.Web.Mvc, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL"</span> <span class="attr">pageBaseType</span><span class="kwrd">="System.Web.Mvc.ViewPage, System.Web.Mvc, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL"</span> <span class="attr">userControlBaseType</span><span class="kwrd">="System.Web.Mvc.ViewUserControl, System.Web.Mvc, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL"</span><span class="kwrd">></span>
Line 16: <span class="kwrd"><</span><span class="html">controls</span><span class="kwrd">></span>
Line 17: <span class="kwrd"><</span><span class="html">add</span> <span class="attr">assembly</span><span class="kwrd">="System.Web.Mvc, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL"</span> <span class="attr">namespace</span><span class="kwrd">="System.Web.Mvc"</span> <span class="attr">tagPrefix</span><span class="kwrd">="mvc"</span> <span class="kwrd">/></span>
Source File: c:\users\admerpe\documents\visual studio 2013\Projects\SVK.Web\SVK.WebUI\modules\bvnetwork.filenotfound.redirectgadget\views\web.config Line: 15
Assembly Load Trace: The following information can be helpful to determine why the assembly 'System.Web.Mvc, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' could not be loaded.
VARN: Loggningen av sammansättningsbindningen är inaktiverad.
Du kan aktivera felloggning för sammansättningsbindningar genom att ange registervärdet [HKLM\Software\Microsoft\Fusion!EnableLog] (DWORD) till 1.
Obs! Prestanda kan försämras något med felloggning för sammansättningsbindningar.
Du kan inaktivera funktionen genom att ta bort registervärdet [HKLM\Software\Microsoft\Fusion!EnableLog].
________________________________________
Version Information: Microsoft .NET Framework Version:4.0.30319; ASP.NET Version:4.0.30319.18446 </code></pre>
<p><style type="text/css">
.csharpcode, .csharpcode pre
{
font-size: small;
color: black;
font-family: consolas, "Courier New", courier, monospace;
background-color: #ffffff;
/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt
{
background-color: #f4f4f4;
width: 100%;
margin: 0em;
}
.csharpcode .lnum { color: #606060; }</style></p>
<h2>The Solution</h2>
<p>And that told us exactly what was wrong. Since my solution is build with MVC we get web.config-files in our views folder. This is also the case for this module. The config-file for this module told us to use MVC 2 but since this was a new computer with the latest installation I did not have MVC 2 installed. </p>
<p>The solution was to copy the config for the <pages>-tag from the web.config in the views-folder. This config file has the 4.0 version.</p>
<pre class="language-csharp"><code> <span class="kwrd"><</span><span class="html">pages</span> <span class="attr">validateRequest</span><span class="kwrd">="false"</span> <span class="attr">pageParserFilterType</span><span class="kwrd">="System.Web.Mvc.ViewTypeParserFilter, System.Web.Mvc, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"</span> <span class="attr">pageBaseType</span><span class="kwrd">="System.Web.Mvc.ViewPage, System.Web.Mvc, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"</span> <span class="attr">userControlBaseType</span><span class="kwrd">="System.Web.Mvc.ViewUserControl, System.Web.Mvc, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"</span><span class="kwrd">></span>
<span class="kwrd"><</span><span class="html">controls</span><span class="kwrd">></span>
<span class="kwrd"><</span><span class="html">add</span> <span class="attr">assembly</span><span class="kwrd">="System.Web.Mvc, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"</span> <span class="attr">namespace</span><span class="kwrd">="System.Web.Mvc"</span> <span class="attr">tagPrefix</span><span class="kwrd">="mvc"</span> <span class="kwrd">/></span>
<span class="kwrd"></</span><span class="html">controls</span><span class="kwrd">></span>
<span class="kwrd"></</span><span class="html">pages</span><span class="kwrd">></span></code></pre>
<p><style type="text/css">
.csharpcode, .csharpcode pre
{
font-size: small;
color: black;
font-family: consolas, "Courier New", courier, monospace;
background-color: #ffffff;
/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt
{
background-color: #f4f4f4;
width: 100%;
margin: 0em;
}
.csharpcode .lnum { color: #606060; }</style></p>
<p>Another solution could be to install MVC 2 but that you will have to test your self. But using Web Platform installer from Microsoft will do it for you if you like to test that your self.</p>
Yet another “Yet another” blog post on how to upgrade CMS 7 to latest CMS (7.9.X)
/blogs/Eric-Pettersson/Dates/2014/7/Yet-another-Yet-another-blog-post-on-how-to-upgrade-CMS-7-to-latest-CMS-79X/
2014-07-14T12:12:39.0000000Z
<p>You sure have done a few upgrades by know but I hadn't. So I thought I would write my experience about upgrading a CMS 7 website to the latest release. There are a few blog post about this subject and I will use them as reference, mainly because they are covering most of the important stuff. <img class="wlEmoticon wlEmoticon-smile" style="border-top-style: none; border-bottom-style: none; border-right-style: none; border-left-style: none" alt="Ler" src="/link/b0a48befc85b4ac5917c1cd90d8fe79e.png" /></p> <p>But since non of them talked about the complete process of upgrading both dev.environment to production this blog post will cover these subjects or at least describe the steps I did to complete a upgrade process from dev to production.</p> <h2>Upgrade your development environment.</h2> <p>Of course we start with dev.environment, but to do so you probably develop the same way I do. By that I mean that you use the local IIS Express server inside Visual Studio. Since upgrading with Deployment Center is the way we upgrade to 7.5 we need to figure out a way to get Deployment Center to find your dev.environment. </p> <p>Since you have everything up and running already you just need to add a new instance in your local IIS server and set the physical path of the new website to your directory, see picture below. </p> <p> </p> <p><a href="/link/3642636850984d33be03d75db892a7ac.png"><img title="pic1" style="border-left-width: 0px; border-right-width: 0px; background-image: none; border-bottom-width: 0px; padding-top: 0px; padding-left: 0px; display: inline; padding-right: 0px; border-top-width: 0px" border="0" alt="pic1" src="/link/8cf579b67f4a46539ae895989c5986b7.png" width="774" height="567" /></a></p> <p> </p> <p>Now you have an instance that you can find with Deployment Center. The upgrade process is straightforward but if you need more information please visit Teds blog post, see reference nr 4.</p> <ol> <li>Run Upgrade site with SQL Server database </li> <li>Run Upgrade/disable addons. </li> </ol> <p>Site is now running on 7.5 so what is next? Before we try to compile our website we need to upgrade our Nuget packages so that we use the latest when building and copying the binaries to the bin-folder.</p> <h3>Upgrade Nuget-packages</h3> <p>EPiServer handles this straightforward and you should be able to upgrade most of your nugets without problem. When that is done you can compile your project. If you like me have used the attribute <strong>AvailablePageTypes,</strong>  you will need to change that to <strong>AvailableContentTypes. </strong></p> <p>Since we are upgrading to the latest version of the CMS, when I wrote this, 7.9.0 we also got changes that we need to install into our database. This is done via the <strong>Nuget Package Manager Console</strong>, see reference 1. If you do not run this you will get an error saying you need to run it <img class="wlEmoticon wlEmoticon-smile" style="border-top-style: none; border-bottom-style: none; border-right-style: none; border-left-style: none" alt="Ler" src="/link/b0a48befc85b4ac5917c1cd90d8fe79e.png" /></p> <p><img title="image" border="0" alt="image" src="/link/92d2d74ba84e4726b59cbef84dd20f6f.png" width="704" height="126" /></p> <p> </p> <p>Ok, now you might think you are done with your development environment. But what I found out was that my <strong>AppData-folder</strong> was source controlled. So when I tried to checkin my upgraded project I got like thousends of errors. The errors were related to the fact that the upgrade process had moved and or deleted files. So when I tried to checkin these files I was not able to. </p> <p>To fix this issue I undid my pending changes for the specific error. Then I deleted the folder from the source control tool instead and made a checkin. The time I spent was like 5 minutes. EPiServer had created new folders for the new versions so it was easy to delete old folders manually.</p> <p>The errors I got was: <strong>..\AppData\ModulesRepository\CMS.2.1.82\CMS.2.1.82.nupkg: Could not find a part of the path </strong></p> <h4>Enable Nuget Package restore for your solution</h4> <p>My project did not use nuget package restore. Since this feature is awesome you should enable that for your project as well. Once that is done you are able to remove all your nuget packages from your repository (TFS/Git). All packages will be downloaded when you compile your project for the first time.</p> <p><a href="/link/0455eed512af40c1a5793d77cdf63928.png"><img title="nugetrestore" style="border-top: 0px; border-right: 0px; background-image: none; border-bottom: 0px; padding-top: 0px; padding-left: 0px; border-left: 0px; display: inline; padding-right: 0px" border="0" alt="nugetrestore" src="/link/626d3cb24c614cfa9f36ba4a8730700a.png" width="424" height="378" /></a></p> <p> </p> <h3>Migrate VPP folders and add content types</h3> <p>Finally we need to migrate the VPP and add support for strongly typed files. Ted has written a great guide for this in his blog post, reference 4. So my suggestion is that you follow his guide. But I would like to add that when you have done this you might need to change a lot of code in your project. In my case I was using ImageResizer.net for croping and image manipulation. The new way of handling files is not supported so we need to do some changes and also add some code to our project.</p> <h3>Changes to make ImageResizer work</h3> <p>After migration of the VPP I got an runtime error saying I had a culture problem but the problem was that ImageResizer did not work properly with the new way of handling images. The error was:</p> <p><a href="/link/418485ac27994349a3ac403ed2fe1136.png"><img title="imageresizer" style="border-top: 0px; border-right: 0px; background-image: none; border-bottom: 0px; padding-top: 0px; padding-left: 0px; border-left: 0px; display: inline; padding-right: 0px" border="0" alt="imageresizer" src="/link/3cfe1365e4a54bf581ce7a762ba78d49.png" width="529" height="315" /></a></p> <p>To fix this I first added this excellent nuget package: <a title="http://nuget.episerver.com/en/OtherPages/Package/?packageId=ImageResizer.Plugins.EPiServerBlobReader" href="http://nuget.episerver.com/en/OtherPages/Package/?packageId=ImageResizer.Plugins.EPiServerBlobReader">http://nuget.episerver.com/en/OtherPages/Package/?packageId=ImageResizer.Plugins.EPiServerBlobReader</a>. I then changed the calls for rendering images to use the new GetUrl:</p> <pre class="language-csharp"><code>UrlResolver.Current.GetUrl(image.Path);</code></pre>
<style type="text/css">
.csharpcode, .csharpcode pre
{
font-size: small;
color: black;
font-family: consolas, "Courier New", courier, monospace;
background-color: #ffffff;
/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt
{
background-color: #f4f4f4;
width: 100%;
margin: 0em;
}
.csharpcode .lnum { color: #606060; }</style>
<p>A couple of changes later I was up and running again.</p>
<p>When all this is done you have updated your dev.environment and can checkin the result. Finally we need to upgrade our production environment and release the new code.</p>
<h2>Upgrading production/test</h2>
<p>Since we have made all changes need to our project and it compiles we can now perform the upgrade on our production environment.</p>
<ul>
<li>Do a complete backup!</li>
<li>Run the scripts from Deployment Center to upgrade to 7.5</li>
<li>Publish code to production</li>
<li>Copy folders for upgrading to 7.9.x</li>
<ul>
<li>Modules – in AppData</li>
<li>ModulesRepository – in Appdata</li>
<li>ModulesBin – in website root</li>
</ul>
</ul>
<p>Since we have upgraded to 7.9.x I needed to deploy the folders that were updated by our nuget packages as well. <strong>If you do not do this edit mode will most likely stop working.</strong></p>
<p>If you remember we also did an upgrade of the database. Now we need to do the same with the production database. In this case we can not run the same script. EPiServer help us with an export of the schema that is independent of visual studio. From Visual Studio you can run <strong>Export-EPiUpdates</strong> in the package manager console. You get a package containing files and scripts that you need to run, see reference 1.</p>
<p>I ran the sql-script directly on my database and I was good to go</p>
<p>No your website should be up and running on the latest release of EPiServer CMS 7.5. </p>
<p>I should add that I keep my config-files for production the same as for dev. Therefore I could publish them as well without any problem. A lot of changes are made to the config-files so before you start be sure you can publish the files you have locally. In my case I used config-transformations for handling different environments.</p>
<h2>Final step</h2>
<p>Download a new license.</p>
<h2>References:</h2>
<ol>
<li><a title="http://world.episerver.com/Blogs/Per-Bjurstrom/Archive/2014/6/NuGet-A-new-database-version-for-CMS/" href="http://world.episerver.com/Blogs/Per-Bjurstrom/Archive/2014/6/NuGet-A-new-database-version-for-CMS/">http://world.episerver.com/Blogs/Per-Bjurstrom/Archive/2014/6/NuGet-A-new-database-version-for-CMS/</a> </li>
<li><a title="http://world.episerver.com/Documentation/Items/Installation-Instructions/Installing-EPiServer-updates/Upgrading-to-EPiServer-75-CMS/" href="http://world.episerver.com/Documentation/Items/Installation-Instructions/Installing-EPiServer-updates/Upgrading-to-EPiServer-75-CMS/">http://world.episerver.com/Documentation/Items/Installation-Instructions/Installing-EPiServer-updates/Upgrading-to-EPiServer-75-CMS/</a> </li>
<li><a title="http://world.episerver.com/Releases/" href="http://world.episerver.com/Releases/">http://world.episerver.com/Releases/</a> </li>
<li><a title="http://tedgustaf.com/blog/2013/12/how-to-upgrade-to-episerver-75/" href="http://tedgustaf.com/blog/2013/12/how-to-upgrade-to-episerver-75/">http://tedgustaf.com/blog/2013/12/how-to-upgrade-to-episerver-75/</a> </li>
<li><a title="http://shahinalborz.se/2014/02/yet-another-how-to-upgrade-to-episerver-7-5/" href="http://shahinalborz.se/2014/02/yet-another-how-to-upgrade-to-episerver-7-5/">http://shahinalborz.se/2014/02/yet-another-how-to-upgrade-to-episerver-7-5/</a> </li>
<li><a title="http://world.episerver.com/Documentation/Items/Developers-Guide/EPiServer-CMS/75/Routing/BLOB-routing/" href="http://world.episerver.com/Documentation/Items/Developers-Guide/EPiServer-CMS/75/Routing/BLOB-routing/">http://world.episerver.com/Documentation/Items/Developers-Guide/EPiServer-CMS/75/Routing/BLOB-routing/</a> </li>
<li><a title="http://world.episerver.com/Documentation/Items/Developers-Guide/EPiServer-CMS/75/Content/Assets-and-media/Content-assets-and-folders/" href="http://world.episerver.com/Documentation/Items/Developers-Guide/EPiServer-CMS/75/Content/Assets-and-media/Content-assets-and-folders/">http://world.episerver.com/Documentation/Items/Developers-Guide/EPiServer-CMS/75/Content/Assets-and-media/Content-assets-and-folders/</a> </li>
</ol>
Are you also having trouble with EPiServer Search (IndexingService.svc) and SSL?
/blogs/Eric-Pettersson/Dates/2014/5/Are-you-also-having-trouble-with-EPiServer-Search-IndexingServicesvc-and-SSL/
2014-05-28T14:25:34.0000000Z
<p>For a long time I have been struggling with getting EPiServer Search up and running on a server with a public url.  Today I also had to struggle with getting the service up and running with SSL. So I thought I should share my experience with you and try to collect a couple resources that might help you getting EPiServer Search up and running.</p> <p>Please feel free to ad comments about this issue as well <img class="wlEmoticon wlEmoticon-smile" style="border-top-style: none; border-bottom-style: none; border-right-style: none; border-left-style: none" alt="Ler" src="/link/ecd6042a8723487a882ad4ff65e56326.png" /> </p> <h3>Are you using Multiple Bindings in IIS?</h3> <p>If so you have to make sure that you add <serviceHostingEnviroment multipleSiteBindingEnable= ”true”>. What is multiple bindings then… well if you are using yoursite.se and yoursite.com you have multiplebindings in your IIS instance for that specific website.</p> <style type="text/css">
.csharpcode, .csharpcode pre
{
font-size: small;
color: black;
font-family: consolas, "Courier New", courier, monospace;
background-color: #ffffff;
/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt
{
background-color: #f4f4f4;
width: 100%;
margin: 0em;
}
.csharpcode .lnum { color: #606060; }</style> <p> </p> <pre class="language-csharp"><code><span class="kwrd"><</span><span class="html">system.serviceModel</span><span class="kwrd">></span>.....
<span class="kwrd"><</span><span class="html">serviceHostingEnvironment</span> <span class="attr">aspNetCompatibilityEnabled</span><span class="kwrd">="true"</span>
<span class="attr">multipleSiteBindingsEnabled</span><span class="kwrd">="true"</span> <span class="kwrd">/></span>
....
<span class="kwrd"></</span><span class="html">system.serviceModel</span><span class="kwrd">></span></code></pre>
<style type="text/css">
.csharpcode, .csharpcode pre
{
font-size: small;
color: black;
font-family: consolas, "Courier New", courier, monospace;
background-color: #ffffff;
/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt
{
background-color: #f4f4f4;
width: 100%;
margin: 0em;
}
.csharpcode .lnum { color: #606060; }</style>
<p> </p>
<h2>Test the IndexingService</h2>
<p>If everything is working as expected you should be able to browse to the “indexingservice.svc”-file. </p>
<p>Browse: <a href="http://yousite.com/indexingservice/indexingservice.svc">http://yousite.com/indexingservice/indexingservice.svc</a>. </p>
<p>You should get this screen:</p>
<p><a href="/link/fdd6301a76784cfbadcc1aced00edbc8.png"><img title="image" style="border-left-width: 0px; border-right-width: 0px; background-image: none; border-bottom-width: 0px; padding-top: 0px; padding-left: 0px; display: inline; padding-right: 0px; border-top-width: 0px" border="0" alt="image" src="/link/71d1a1d0ba4a4249b1cb542c9a044ef7.png" width="373" height="269" /></a></p>
<h3>You are getting a 404 or other error message saying that it is not working?</h3>
<p>First thing you should look at is if you have the Indexingservice installed on your server. Check the Deployment Center for the EPiServer Search module. Second make sure you have the folder specified in web.config for indexingservice. Should be a folder in your wwwroot-folder “Indexingservice/indexingservice.svc”</p>
<p>Still not luck with the service? </p>
<p>Ok now we need to make sure we have the WCF installed correctly on the IIS. Todo that you can ran the following command in your Command Prompt:</p>
<p><strong>SystemServiceModelReg.exe</strong> – The tool can be found in the following directory: %SystemRoot%\Microsoft.Net\Framework\v3.0\Windows Communication Foundation\</p>
<h3>And still no Index? </h3>
<p>There are a few thing you could check if you still have no working index and search on you website.</p>
<ul>
<li>ReIndex your website
<ul>
<li>There is a secret gem in EPiServer Admin-mode, browse: “<a title="http://yoursite/EPiServer/CMS/Admin/IndexContent.aspx" href="http://yoursite/EPiServer/CMS/Admin/IndexContent.aspx">http://yoursite/EPiServer/CMS/Admin/IndexContent.aspx</a>” </li>
</ul>
</li>
<li>Make sure the service is indexing your server locally
<ul>
<li>Add the public url to the host-file on the server: 127.0.0.1   yoursiterurl.com
<ul>
<li>File located in:  C:\Windows\System32\drivers\etc </li>
</ul>
</li>
</ul>
</li>
</ul>
<p> </p>
<h2>Configure EPiServer Search with SSL</h2>
<p>Last but not least. If you have SSL enabled on your website you will get a 404 message for your service. You will need to change some settings in web.config. To enable wcf service to work with SSL you just need to add the following:</p>
<pre class="language-csharp"><code> <span class="kwrd"><</span><span class="html">binding</span> <span class="attr">name</span><span class="kwrd">="IndexingServiceCustomBinding"</span>
<span class="attr">maxBufferPoolSize</span><span class="kwrd">="1073741824"</span>
<span class="attr">maxReceivedMessageSize</span><span class="kwrd">="2147483647"</span>
<span class="attr">maxBufferSize</span><span class="kwrd">="2147483647"</span><span class="kwrd">></span>
<span class="kwrd"><</span><span class="html">security</span> <span class="attr">mode</span><span class="kwrd">="Transport"</span><span class="kwrd">></span>
<span class="kwrd"><</span><span class="html">transport</span> <span class="attr">clientCredentialType</span><span class="kwrd">="None"</span><span class="kwrd">></</span><span class="html">transport</span><span class="kwrd">></span>
<span class="kwrd"></</span><span class="html">security</span><span class="kwrd">></span>
<span class="kwrd"><</span><span class="html">readerQuotas</span> <span class="attr">maxStringContentLength</span><span class="kwrd">="10000000"</span> <span class="kwrd">/></span>
<span class="kwrd"></</span><span class="html">binding</span><span class="kwrd">></span></code></pre>
<style type="text/css">
.csharpcode, .csharpcode pre
{
font-size: small;
color: black;
font-family: consolas, "Courier New", courier, monospace;
background-color: #ffffff;
/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt
{
background-color: #f4f4f4;
width: 100%;
margin: 0em;
}
.csharpcode .lnum { color: #606060; }</style>
<p>The important part is to add:</p>
<pre class="language-csharp"><code><span class="kwrd"><</span><span class="html">security</span> <span class="attr">mode</span><span class="kwrd">="Transport"</span><span class="kwrd">></span>
<span class="kwrd"><</span><span class="html">transport</span> <span class="attr">clientCredentialType</span><span class="kwrd">="None"</span><span class="kwrd">></</span><span class="html">transport</span><span class="kwrd">></span>
<span class="kwrd"></</span><span class="html">security</span><span class="kwrd">></span></code></pre>
<style type="text/css">
.csharpcode, .csharpcode pre
{
font-size: small;
color: black;
font-family: consolas, "Courier New", courier, monospace;
background-color: #ffffff;
/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt
{
background-color: #f4f4f4;
width: 100%;
margin: 0em;
}
.csharpcode .lnum { color: #606060; }</style>
<div class="csharpcode"><font face="Calibri"></font></div>
<p>If your website use both secure and none secure http you can and a new CustomBinding to your web.config</p>
<h3> </h3>
<h3>Links that might help you and references.</h3>
<ul>
<li><a href="http://msdn.microsoft.com/en-us/library/ms732012%28v=vs.110%29.aspx">ServiceModel Registration Tool (ServiceModelReg.exe)</a> </li>
<li><a href="http://sveinaandahl.blogspot.se/2013/06/how-to-install-episerver-search-for.html">How to install EPiServer Search for EPiServer CMS 7</a> </li>
<li><a href="http://msdn.microsoft.com/en-us/library/hh556232%28v=vs.110%29.aspx">How to: Configure an IIS-hosted WCF service with SSL</a> </li>
<li><a href="http://blog.huilaaja.net/2013/05/05/using-indexing-service-with-both-http-and-https/">Using EPiServer Search with SSL</a></li>
<li><a href="/link/34be076b6e9a40bca082a4ec18059ce8.aspx">IndexingService not mapped</a> </li>
</ul>
Things you should consider regarding client-side performance before releasing a website.
/blogs/Eric-Pettersson/Dates/2013/6/Things-you-should-consider-regarding-client-side-performance-before-releasing-a-website/
2013-06-24T16:25:14.0000000Z
<p>Lately I have been working with websites built a year ago or more and one thing that I always get surprised by is that none of them have implemented any compression or rules for improving client side performance. You might think that these websites are old and we did not look at things like that. But… back in 2010 I was at a conference in USA where they talked about compression of css and js and even though that was 3 years ago I remember the colleagues that I were there with said that this is something we already use and have been for a while. So why are we not implementing simple things like compression at all times since then?</p> <p>I know that this subject has been written about before but we seem to forget or ignore, Fredrik Vig wrote a great post about this subject a couple of years ago, <a href="http://www.frederikvig.com/2011/10/faster-episerver-sites-client-side-performance/">http://www.frederikvig.com/2011/10/faster-episerver-sites-client-side-performance/</a></p> <p>So how is it that we do not implement simple rules and functions to our projects before we release them? By doing such small amount of work you can reach so far into fixing the performance of your website. Sadly most of the time we do not plan for this and therefore we do not have time to implement all of it, we tend to focus on setting up environments with CI or web deploy and many more nice to have features but we obviously forget about performance. <strong>But you must add some at least specially in times for Responsive Web Design!</strong></p> <p> </p> <h2>Web Performance Optimazation (<a href="http://en.wikipedia.org/wiki/Web_performance_optimization">WPO</a>)</h2> <p>This can seem like a big and intimidating task but it is actually really easy to apply to your project and the 80/20-rule can be applied, small effort will get 80% of the result.</p> <p>When RWD became popular this subject became important since mobile devices might use slow connections and more and more people start to access you website from other places then at the office = great internet connection..</p> <h2>Compress/Bundle JS and CSS and finally load them async</h2> <p>Most of our development in js-files and css-files are done in more then one file for easier development. But most of the current browser limit the number of connections to six. That means it will take time to download many resources and resources will be queued while processing the first six requests. By bundling files we can limit the requests. Also a lot of the tools will perform minification on files, deleting whitespace and line breaks, that will reduce file-size.</p> <p>As I am not a fan of “cool” plugins to VS I suggest using Nuget and install plugins such as Microsoft Web Optimization.</p> <ul> <li><a title="http://nuget.org/packages/Microsoft.AspNet.Web.Optimization/1.0.0" href="http://nuget.org/packages/Microsoft.AspNet.Web.Optimization/1.0.0">http://nuget.org/packages/Microsoft.AspNet.Web.Optimization/1.0.0</a> </li> <li><a title="http://blogs.msdn.com/b/rickandy/archive/2012/08/14/adding-bundling-and-minification-to-web-forms.aspx" href="http://blogs.msdn.com/b/rickandy/archive/2012/08/14/adding-bundling-and-minification-to-web-forms.aspx">http://blogs.msdn.com/b/rickandy/archive/2012/08/14/adding-bundling-and-minification-to-web-forms.aspx</a> </li> <li><a title="http://www.asp.net/mvc/tutorials/mvc-4/bundling-and-minification" href="http://www.asp.net/mvc/tutorials/mvc-4/bundling-and-minification">http://www.asp.net/mvc/tutorials/mvc-4/bundling-and-minification</a> </li> </ul> <p>JavaScript is probably killing your site and making it slow!? Optimizing scripts could take a lot of time so instead of doing that we bundle them and try to load them asynchronously to stop script from blocking the rest of the page. We need to focus on sending less JavaScript, use smaller libraries, especially on mobile devices. </p> <p>More information about JavaScript loaders: </p> <ul> <li><a title="http://css-tricks.com/thinking-async/" href="http://css-tricks.com/thinking-async/">http://css-tricks.com/thinking-async/</a> </li> <li><a title="http://www.netmagazine.com/features/essential-javascript-top-five-script-loaders" href="http://www.netmagazine.com/features/essential-javascript-top-five-script-loaders">http://www.netmagazine.com/features/essential-javascript-top-five-script-loaders</a> </li> </ul> <h2>Optimizing images</h2> <p>Working with images has always been a pain when it comes to the web. As a developer I try to make a great website exactly like the Art Director says, sadly editors do not have the same way of thinking when it comes to images and specially the size of them. As a developer working with CMS we need to understand that this might be an issue and write code that will create images with correct size and optimized for the web.</p> <p>First we need to pick the right format for images: PNG for icons and graphics, JPEG for photos and GIF only for animations (if you still need that). </p> <p>If you are a developer that also create images, make sure you save them with the lowest tolerable quality. As a developer there are some tools that you can use in Visual Studio that will optimize your local images, for instance, <a href="http://visualstudiogallery.msdn.microsoft.com/a56eddd3-d79b-48ac-8c8f-2db06ade77c3">Image Optimizer</a></p> <p>Once you have uploaded your images to EPiServer we need to optimize them on output as well. We can then implement a lossless image optimizer like ImageOptim, <a href="http://imageoptim.com">http://imageoptim.com</a>, or Smush.it, <a href="http://www.smushit.com">http://www.smushit.com</a>. These tools will squeeze the bytes from the images.</p> <p>A great tool is the plugin written by Geta and Fredrik Vig in Norway, <a title="http://www.frederikvig.com/2012/05/faster-episerver-sites-image-optimization/" href="http://www.frederikvig.com/2012/05/faster-episerver-sites-image-optimization/">http://www.frederikvig.com/2012/05/faster-episerver-sites-image-optimization/</a>. </p> <h3>What about using the right size for images both desktop and mobile? </h3> <p>After we are done with optimizing the size of image we need to look into loading images from EPiServer for different resolutions. We need to scale them so they fit our needs. Using larger images then needed is not that great for performance. </p> <p>In this case I suggest looking into using Adaptive Images, <a title="http://adaptive-images.com/" href="http://adaptive-images.com/">http://adaptive-images.com/</a>. A blogpost has also been written about this, <a title="http://blog.huilaaja.net/2013/03/28/adaptive-images/" href="http://blog.huilaaja.net/2013/03/28/adaptive-images/">http://blog.huilaaja.net/2013/03/28/adaptive-images/</a></p> <h2>Test your performance</h2> <p>When you are done with all the compression and image optimization you probably would like to test your website. This can easily be done by using plugins to Firebug such as YSlow and Google PageSpeed</p> <ul> <li><a title="http://yslow.org/" href="http://yslow.org/">http://yslow.org/</a> </li> <li><a title="https://developers.google.com/speed/pagespeed/insights_extensions" href="https://developers.google.com/speed/pagespeed/insights_extensions">https://developers.google.com/speed/pagespeed/insights_extensions</a> </li> </ul> <p> </p> <p><a href="/link/48d7a12cd4704b08a0043b4a6bd0fa08.png"><img title="image" style="border-left-width: 0px; border-right-width: 0px; background-image: none; border-bottom-width: 0px; padding-top: 0px; padding-left: 0px; display: inline; padding-right: 0px; border-top-width: 0px" border="0" alt="image" src="/link/edf4f36fa0dc4b4da881ccde06f5c18b.png" width="508" height="351" /></a></p> <h6>Bild: YSlow</h6> <p><a href="/link/daad4d975f704374993b80fa5fb4cd19.png"><img title="Google PageSpeed" style="border-left-width: 0px; border-right-width: 0px; background-image: none; border-bottom-width: 0px; padding-top: 0px; padding-left: 0px; display: inline; padding-right: 0px; border-top-width: 0px" border="0" alt="Google PageSpeed" src="/link/924570b1fbbb4bf4b075feb4e68fcc9f.png" width="571" height="181" /></a></p> <h6>Bild: Google PageSpeed</h6> <p>This might become handy when you are a developer but you can also test you website using the online with tools like: WebPageTest (<a title="http://www.webpagetest.org/" href="http://www.webpagetest.org/">http://www.webpagetest.org/</a>) or Google PageSpeed (<a title="https://developers.google.com/speed/pagespeed/" href="https://developers.google.com/speed/pagespeed/">https://developers.google.com/speed/pagespeed/</a>)</p> <p> </p> <h2>Summary</h2> <p>There are a lot of improvements that can be done with small amount of both time and effort. The things I have mentioned should be added to every project. Of course we can do so much more but at least it is a start.</p> <ul> <li>Use a CDN </li> <li>Use Sprites for images. </li> <li>Embed images as resources in css. </li> <li>Add cache to both EPiServer and static files. </li> <li>Add Expires headers </li> <li>Compress your components using gzip – is very easy in IIS 7 and above. </li> </ul> <h3>Resources</h3> <ul> <li><a title="http://www.webpagetest.org/" href="http://www.webpagetest.org/">http://www.webpagetest.org/</a> – <em>“Run a free website speed test from multiple locations around the globe using real browsers (IE and Chrome) and at real consumer connection speeds. You can run simple tests or perform advanced testing including multi-step transactions, video capture, content blocking and much more. Your results will provide rich diagnostic information including resource loading waterfall charts, Page Speed optimization checks and suggestions for improvements.”</em> </li> <li><a title="https://developers.google.com/speed/" href="https://developers.google.com/speed/">https://developers.google.com/speed/</a> – Great resource from Google about page speed. </li> <li><a title="https://developers.google.com/speed/docs/best-practices/mobile" href="https://developers.google.com/speed/docs/best-practices/mobile">https://developers.google.com/speed/docs/best-practices/mobile</a> – Things to consider when working with mobile devices. </li> <li><a title="http://en.wikipedia.org/wiki/Web_performance_optimization" href="http://en.wikipedia.org/wiki/Web_performance_optimization">http://en.wikipedia.org/wiki/Web_performance_optimization</a> – Definition of WPO and some great links. </li> </ul>
Use Xform to store data when you have a form with a fixed design
/blogs/Eric-Pettersson/Dates/2013/3/Use-Xform-to-store-data-when-you-have-a-form-with-a-fixed-design/
2013-03-28T09:40:39.0000000Z
<p>Many of you have probably used xform before and also hate the fact that when the editor create a form inside EPiServer you can not set the layout and design as you like. But xform can be ok to use when store information/data when you have a form that have a specific design and layout or when the editor are not allowed to choose the fields to use. </p> <p>Since almost every blogpost is about CMS 7 and MVC at the moment I thought this post might help someone still working with CMS 6 or doing ordinary good old EPiServer development <img class="wlEmoticon wlEmoticon-smile" style="border-top-style: none; border-left-style: none; border-bottom-style: none; border-right-style: none" alt="Ler" src="/link/0fc83ec9678c488a8ffa7a21aaf822e3.png" /></p> <p>Lately I have been working with a customer that needed a contact form looking something like this:</p> <p><a href="/link/ede0869a2e85439b85106ef78acf0d52.png"><img title="image" style="border-top: 0px; border-right: 0px; background-image: none; border-bottom: 0px; padding-top: 0px; padding-left: 0px; border-left: 0px; display: inline; padding-right: 0px" border="0" alt="image" src="/link/c9d02286db074fda8728eed6632ee33d.png" width="554" height="344" /></a></p> <p> </p> <p>They hade some requirements for validation and my part in the project was to create the functionality and store the information. The html/css-part was already made by another developer therefore I could note create css and html to fit the ordinary tags that EPiServer Xform will create when you use it as an editor to produce forms.</p> <p>But since EPiServer allow use to store information in Xform with the API we can create a form locking exactly like this and with the built-in functionality in EPiServer let the editor collect data. This is very simple. <img class="wlEmoticon wlEmoticon-smile" style="border-top-style: none; border-left-style: none; border-bottom-style: none; border-right-style: none" alt="Ler" src="/link/0fc83ec9678c488a8ffa7a21aaf822e3.png" /></p> <ol> <li>Create a property of type Xform on the specific PageType</li> <li>Create an empty form and set the property to use that form</li> </ol> <p>The rest is done by code. First we need to create our form in html. With the help of web controls we can also use some validation. If you do not like to use validation you can delete the web controls handling validation. </p> <div id="codeSnippetWrapper" style="overflow: auto; cursor: text; font-size: 8pt; border-top: silver 1px solid; font-family: 'Courier New', courier, monospace; border-right: silver 1px solid; border-bottom: silver 1px solid; padding-bottom: 4px; direction: ltr; text-align: left; padding-top: 4px; padding-left: 4px; margin: 20px 0px 10px; border-left: silver 1px solid; line-height: 12pt; padding-right: 4px; max-height: 200px; width: 97.5%; background-color: #f4f4f4"> <div id="codeSnippet" style="border-top-style: none; overflow: visible; font-size: 8pt; border-left-style: none; font-family: 'Courier New', courier, monospace; border-bottom-style: none; color: black; padding-bottom: 0px; direction: ltr; text-align: left; padding-top: 0px; border-right-style: none; padding-left: 0px; line-height: 12pt; padding-right: 0px; width: 100%; background-color: #f4f4f4"> <pre style="border-top-style: none; overflow: visible; font-size: 8pt; border-left-style: none; font-family: 'Courier New', courier, monospace; border-bottom-style: none; color: black; padding-bottom: 0px; direction: ltr; text-align: left; padding-top: 0px; border-right-style: none; padding-left: 0px; margin: 0em; line-height: 12pt; padding-right: 0px; width: 100%; background-color: white"><span id="lnum1" style="color: #606060"> 1:</span> <span style="color: #0000ff"><</span><span style="color: #800000">div</span> <span style="color: #ff0000">class</span><span style="color: #0000ff">="form"</span><span style="color: #0000ff">></span></pre>
<!--CRLF-->
<pre style="border-top-style: none; overflow: visible; font-size: 8pt; border-left-style: none; font-family: 'Courier New', courier, monospace; border-bottom-style: none; color: black; padding-bottom: 0px; direction: ltr; text-align: left; padding-top: 0px; border-right-style: none; padding-left: 0px; margin: 0em; line-height: 12pt; padding-right: 0px; width: 100%; background-color: #f4f4f4"><span id="lnum2" style="color: #606060"> 2:</span> <span style="color: #0000ff"><</span><span style="color: #800000">div</span> <span style="color: #ff0000">class</span><span style="color: #0000ff">="form-fields"</span><span style="color: #0000ff">></span></pre>
<!--CRLF-->
<pre style="border-top-style: none; overflow: visible; font-size: 8pt; border-left-style: none; font-family: 'Courier New', courier, monospace; border-bottom-style: none; color: black; padding-bottom: 0px; direction: ltr; text-align: left; padding-top: 0px; border-right-style: none; padding-left: 0px; margin: 0em; line-height: 12pt; padding-right: 0px; width: 100%; background-color: white"><span id="lnum3" style="color: #606060"> 3:</span> <span style="color: #0000ff"><</span><span style="color: #800000">div</span> <span style="color: #ff0000">class</span><span style="color: #0000ff">="input"</span><span style="color: #0000ff">></span></pre>
<!--CRLF-->
<pre style="border-top-style: none; overflow: visible; font-size: 8pt; border-left-style: none; font-family: 'Courier New', courier, monospace; border-bottom-style: none; color: black; padding-bottom: 0px; direction: ltr; text-align: left; padding-top: 0px; border-right-style: none; padding-left: 0px; margin: 0em; line-height: 12pt; padding-right: 0px; width: 100%; background-color: #f4f4f4"><span id="lnum4" style="color: #606060"> 4:</span> <span style="color: #0000ff"><</span><span style="color: #800000">asp:Label</span> <span style="color: #ff0000">runat</span><span style="color: #0000ff">="server"</span> <span style="color: #ff0000">ID</span><span style="color: #0000ff">="lblName"</span> <span style="color: #ff0000">AssociatedControlID</span><span style="color: #0000ff">="txtName"</span><span style="color: #0000ff">></span>Namn:<span style="color: #0000ff"></</span><span style="color: #800000">asp:Label</span><span style="color: #0000ff">></span></pre>
<!--CRLF-->
<pre style="border-top-style: none; overflow: visible; font-size: 8pt; border-left-style: none; font-family: 'Courier New', courier, monospace; border-bottom-style: none; color: black; padding-bottom: 0px; direction: ltr; text-align: left; padding-top: 0px; border-right-style: none; padding-left: 0px; margin: 0em; line-height: 12pt; padding-right: 0px; width: 100%; background-color: white"><span id="lnum5" style="color: #606060"> 5:</span> <span style="color: #0000ff"><</span><span style="color: #800000">asp:TextBox</span> <span style="color: #ff0000">runat</span><span style="color: #0000ff">="server"</span> <span style="color: #ff0000">ID</span><span style="color: #0000ff">="txtName"</span> <span style="color: #ff0000">ValidationGroup</span><span style="color: #0000ff">="form"</span><span style="color: #0000ff">></</span><span style="color: #800000">asp:TextBox</span><span style="color: #0000ff">></span></pre>
<!--CRLF-->
<pre style="border-top-style: none; overflow: visible; font-size: 8pt; border-left-style: none; font-family: 'Courier New', courier, monospace; border-bottom-style: none; color: black; padding-bottom: 0px; direction: ltr; text-align: left; padding-top: 0px; border-right-style: none; padding-left: 0px; margin: 0em; line-height: 12pt; padding-right: 0px; width: 100%; background-color: #f4f4f4"><span id="lnum6" style="color: #606060"> 6:</span> <span style="color: #0000ff"><</span><span style="color: #800000">asp:RequiredFieldValidator</span> <span style="color: #ff0000">ID</span><span style="color: #0000ff">="RequiredFieldValidator1"</span> <span style="color: #ff0000">runat</span><span style="color: #0000ff">="server"</span> <span style="color: #ff0000">ControlToValidate</span><span style="color: #0000ff">="txtName"</span> <span style="color: #ff0000">ErrorMessage</span><span style="color: #0000ff">="Vill vill gärna ha ditt namn!"</span> <span style="color: #ff0000">ValidationGroup</span><span style="color: #0000ff">="form"</span> <span style="color: #ff0000">Display</span><span style="color: #0000ff">="Dynamic"</span><span style="color: #0000ff">></</span><span style="color: #800000">asp:RequiredFieldValidator</span><span style="color: #0000ff">></span></pre>
<!--CRLF-->
<pre style="border-top-style: none; overflow: visible; font-size: 8pt; border-left-style: none; font-family: 'Courier New', courier, monospace; border-bottom-style: none; color: black; padding-bottom: 0px; direction: ltr; text-align: left; padding-top: 0px; border-right-style: none; padding-left: 0px; margin: 0em; line-height: 12pt; padding-right: 0px; width: 100%; background-color: white"><span id="lnum7" style="color: #606060"> 7:</span> <span style="color: #0000ff"></</span><span style="color: #800000">div</span><span style="color: #0000ff">></span></pre>
<!--CRLF-->
<pre style="border-top-style: none; overflow: visible; font-size: 8pt; border-left-style: none; font-family: 'Courier New', courier, monospace; border-bottom-style: none; color: black; padding-bottom: 0px; direction: ltr; text-align: left; padding-top: 0px; border-right-style: none; padding-left: 0px; margin: 0em; line-height: 12pt; padding-right: 0px; width: 100%; background-color: #f4f4f4"><span id="lnum8" style="color: #606060"> 8:</span> <span style="color: #0000ff"><</span><span style="color: #800000">div</span> <span style="color: #ff0000">class</span><span style="color: #0000ff">="input"</span><span style="color: #0000ff">></span></pre>
<!--CRLF-->
<pre style="border-top-style: none; overflow: visible; font-size: 8pt; border-left-style: none; font-family: 'Courier New', courier, monospace; border-bottom-style: none; color: black; padding-bottom: 0px; direction: ltr; text-align: left; padding-top: 0px; border-right-style: none; padding-left: 0px; margin: 0em; line-height: 12pt; padding-right: 0px; width: 100%; background-color: white"><span id="lnum9" style="color: #606060"> 9:</span> <span style="color: #0000ff"><</span><span style="color: #800000">asp:Label</span> <span style="color: #ff0000">runat</span><span style="color: #0000ff">="server"</span> <span style="color: #ff0000">ID</span><span style="color: #0000ff">="lblMail"</span> <span style="color: #ff0000">AssociatedControlID</span><span style="color: #0000ff">="txtMail"</span><span style="color: #0000ff">></span>E-post:<span style="color: #0000ff"></</span><span style="color: #800000">asp:Label</span><span style="color: #0000ff">></span></pre>
<!--CRLF-->
<pre style="border-top-style: none; overflow: visible; font-size: 8pt; border-left-style: none; font-family: 'Courier New', courier, monospace; border-bottom-style: none; color: black; padding-bottom: 0px; direction: ltr; text-align: left; padding-top: 0px; border-right-style: none; padding-left: 0px; margin: 0em; line-height: 12pt; padding-right: 0px; width: 100%; background-color: #f4f4f4"><span id="lnum10" style="color: #606060"> 10:</span> <span style="color: #0000ff"><</span><span style="color: #800000">asp:TextBox</span> <span style="color: #ff0000">runat</span><span style="color: #0000ff">="server"</span> <span style="color: #ff0000">ID</span><span style="color: #0000ff">="txtMail"</span> <span style="color: #ff0000">ValidationGroup</span><span style="color: #0000ff">="form"</span><span style="color: #0000ff">></</span><span style="color: #800000">asp:TextBox</span><span style="color: #0000ff">></span></pre>
<!--CRLF-->
<pre style="border-top-style: none; overflow: visible; font-size: 8pt; border-left-style: none; font-family: 'Courier New', courier, monospace; border-bottom-style: none; color: black; padding-bottom: 0px; direction: ltr; text-align: left; padding-top: 0px; border-right-style: none; padding-left: 0px; margin: 0em; line-height: 12pt; padding-right: 0px; width: 100%; background-color: white"><span id="lnum11" style="color: #606060"> 11:</span> <span style="color: #0000ff"><</span><span style="color: #800000">asp:RequiredFieldValidator</span> <span style="color: #ff0000">runat</span><span style="color: #0000ff">="server"</span> <span style="color: #ff0000">ControlToValidate</span><span style="color: #0000ff">="txtMail"</span> <span style="color: #ff0000">ValidationGroup</span><span style="color: #0000ff">="form"</span> <span style="color: #ff0000">ErrorMessage</span><span style="color: #0000ff">="Fyll i din epost så vi kan kontakta dig!"</span> <span style="color: #ff0000">Display</span><span style="color: #0000ff">="Dynamic"</span><span style="color: #0000ff">></</span><span style="color: #800000">asp:RequiredFieldValidator</span><span style="color: #0000ff">></span></pre>
<!--CRLF-->
<pre style="border-top-style: none; overflow: visible; font-size: 8pt; border-left-style: none; font-family: 'Courier New', courier, monospace; border-bottom-style: none; color: black; padding-bottom: 0px; direction: ltr; text-align: left; padding-top: 0px; border-right-style: none; padding-left: 0px; margin: 0em; line-height: 12pt; padding-right: 0px; width: 100%; background-color: #f4f4f4"><span id="lnum12" style="color: #606060"> 12:</span> <span style="color: #0000ff"><</span><span style="color: #800000">asp:RegularExpressionValidator</span> <span style="color: #ff0000">runat</span><span style="color: #0000ff">="server"</span> <span style="color: #ff0000">ValidationExpression</span><span style="color: #0000ff">=".*@.*\..*"</span> <span style="color: #ff0000">ErrorMessage</span><span style="color: #0000ff">="Felaktig e-post"</span> <span style="color: #ff0000">ControlToValidate</span><span style="color: #0000ff">="txtMail"</span> <span style="color: #ff0000">Display</span><span style="color: #0000ff">="Dynamic"</span> <span style="color: #ff0000">ValidationGroup</span><span style="color: #0000ff">="form"</span><span style="color: #0000ff">></</span><span style="color: #800000">asp:RegularExpressionValidator</span><span style="color: #0000ff">></span></pre>
<!--CRLF-->
<pre style="border-top-style: none; overflow: visible; font-size: 8pt; border-left-style: none; font-family: 'Courier New', courier, monospace; border-bottom-style: none; color: black; padding-bottom: 0px; direction: ltr; text-align: left; padding-top: 0px; border-right-style: none; padding-left: 0px; margin: 0em; line-height: 12pt; padding-right: 0px; width: 100%; background-color: white"><span id="lnum13" style="color: #606060"> 13:</span> <span style="color: #0000ff"></</span><span style="color: #800000">div</span><span style="color: #0000ff">></span></pre>
<!--CRLF-->
<pre style="border-top-style: none; overflow: visible; font-size: 8pt; border-left-style: none; font-family: 'Courier New', courier, monospace; border-bottom-style: none; color: black; padding-bottom: 0px; direction: ltr; text-align: left; padding-top: 0px; border-right-style: none; padding-left: 0px; margin: 0em; line-height: 12pt; padding-right: 0px; width: 100%; background-color: #f4f4f4"><span id="lnum14" style="color: #606060"> 14:</span> <span style="color: #0000ff"><</span><span style="color: #800000">div</span> <span style="color: #ff0000">class</span><span style="color: #0000ff">="input"</span><span style="color: #0000ff">></span></pre>
<!--CRLF-->
<pre style="border-top-style: none; overflow: visible; font-size: 8pt; border-left-style: none; font-family: 'Courier New', courier, monospace; border-bottom-style: none; color: black; padding-bottom: 0px; direction: ltr; text-align: left; padding-top: 0px; border-right-style: none; padding-left: 0px; margin: 0em; line-height: 12pt; padding-right: 0px; width: 100%; background-color: white"><span id="lnum15" style="color: #606060"> 15:</span> <span style="color: #0000ff"><</span><span style="color: #800000">asp:Label</span> <span style="color: #ff0000">runat</span><span style="color: #0000ff">="server"</span> <span style="color: #ff0000">ID</span><span style="color: #0000ff">="lblCompany"</span> <span style="color: #ff0000">AssociatedControlID</span><span style="color: #0000ff">="txtCompany"</span><span style="color: #0000ff">></span>Företag:<span style="color: #0000ff"></</span><span style="color: #800000">asp:Label</span><span style="color: #0000ff">></span></pre>
<!--CRLF-->
<pre style="border-top-style: none; overflow: visible; font-size: 8pt; border-left-style: none; font-family: 'Courier New', courier, monospace; border-bottom-style: none; color: black; padding-bottom: 0px; direction: ltr; text-align: left; padding-top: 0px; border-right-style: none; padding-left: 0px; margin: 0em; line-height: 12pt; padding-right: 0px; width: 100%; background-color: #f4f4f4"><span id="lnum16" style="color: #606060"> 16:</span> <span style="color: #0000ff"><</span><span style="color: #800000">asp:TextBox</span> <span style="color: #ff0000">runat</span><span style="color: #0000ff">="server"</span> <span style="color: #ff0000">ID</span><span style="color: #0000ff">="txtCompany"</span> <span style="color: #ff0000">ValidationGroup</span><span style="color: #0000ff">="form"</span><span style="color: #0000ff">></</span><span style="color: #800000">asp:TextBox</span><span style="color: #0000ff">></span></pre>
<!--CRLF-->
<pre style="border-top-style: none; overflow: visible; font-size: 8pt; border-left-style: none; font-family: 'Courier New', courier, monospace; border-bottom-style: none; color: black; padding-bottom: 0px; direction: ltr; text-align: left; padding-top: 0px; border-right-style: none; padding-left: 0px; margin: 0em; line-height: 12pt; padding-right: 0px; width: 100%; background-color: white"><span id="lnum17" style="color: #606060"> 17:</span> <span style="color: #0000ff"></</span><span style="color: #800000">div</span><span style="color: #0000ff">></span></pre>
<!--CRLF-->
<pre style="border-top-style: none; overflow: visible; font-size: 8pt; border-left-style: none; font-family: 'Courier New', courier, monospace; border-bottom-style: none; color: black; padding-bottom: 0px; direction: ltr; text-align: left; padding-top: 0px; border-right-style: none; padding-left: 0px; margin: 0em; line-height: 12pt; padding-right: 0px; width: 100%; background-color: #f4f4f4"><span id="lnum18" style="color: #606060"> 18:</span> <span style="color: #0000ff"><</span><span style="color: #800000">div</span> <span style="color: #ff0000">class</span><span style="color: #0000ff">="input"</span><span style="color: #0000ff">></span></pre>
<!--CRLF-->
<pre style="border-top-style: none; overflow: visible; font-size: 8pt; border-left-style: none; font-family: 'Courier New', courier, monospace; border-bottom-style: none; color: black; padding-bottom: 0px; direction: ltr; text-align: left; padding-top: 0px; border-right-style: none; padding-left: 0px; margin: 0em; line-height: 12pt; padding-right: 0px; width: 100%; background-color: white"><span id="lnum19" style="color: #606060"> 19:</span> <span style="color: #0000ff"><</span><span style="color: #800000">asp:Label</span> <span style="color: #ff0000">runat</span><span style="color: #0000ff">="server"</span> <span style="color: #ff0000">ID</span><span style="color: #0000ff">="lblPhone"</span> <span style="color: #ff0000">AssociatedControlID</span><span style="color: #0000ff">="txtPhone"</span><span style="color: #0000ff">></span>Telefonnummer:<span style="color: #0000ff"></</span><span style="color: #800000">asp:Label</span><span style="color: #0000ff">></span></pre>
<!--CRLF-->
<pre style="border-top-style: none; overflow: visible; font-size: 8pt; border-left-style: none; font-family: 'Courier New', courier, monospace; border-bottom-style: none; color: black; padding-bottom: 0px; direction: ltr; text-align: left; padding-top: 0px; border-right-style: none; padding-left: 0px; margin: 0em; line-height: 12pt; padding-right: 0px; width: 100%; background-color: #f4f4f4"><span id="lnum20" style="color: #606060"> 20:</span> <span style="color: #0000ff"><</span><span style="color: #800000">asp:TextBox</span> <span style="color: #ff0000">runat</span><span style="color: #0000ff">="server"</span> <span style="color: #ff0000">ID</span><span style="color: #0000ff">="txtPhone"</span> <span style="color: #ff0000">ValidationGroup</span><span style="color: #0000ff">="form"</span><span style="color: #0000ff">></</span><span style="color: #800000">asp:TextBox</span><span style="color: #0000ff">></span></pre>
<!--CRLF-->
<pre style="border-top-style: none; overflow: visible; font-size: 8pt; border-left-style: none; font-family: 'Courier New', courier, monospace; border-bottom-style: none; color: black; padding-bottom: 0px; direction: ltr; text-align: left; padding-top: 0px; border-right-style: none; padding-left: 0px; margin: 0em; line-height: 12pt; padding-right: 0px; width: 100%; background-color: white"><span id="lnum21" style="color: #606060"> 21:</span>  </pre>
<!--CRLF-->
<pre style="border-top-style: none; overflow: visible; font-size: 8pt; border-left-style: none; font-family: 'Courier New', courier, monospace; border-bottom-style: none; color: black; padding-bottom: 0px; direction: ltr; text-align: left; padding-top: 0px; border-right-style: none; padding-left: 0px; margin: 0em; line-height: 12pt; padding-right: 0px; width: 100%; background-color: #f4f4f4"><span id="lnum22" style="color: #606060"> 22:</span> <span style="color: #0000ff"><</span><span style="color: #800000">asp:RequiredFieldValidator</span> <span style="color: #ff0000">runat</span><span style="color: #0000ff">="server"</span> <span style="color: #ff0000">ControlToValidate</span><span style="color: #0000ff">="txtPhone"</span> <span style="color: #ff0000">ValidationGroup</span><span style="color: #0000ff">="form"</span> <span style="color: #ff0000">ErrorMessage</span><span style="color: #0000ff">="Du måste ange ett telefonnummer"</span> <span style="color: #ff0000">Display</span><span style="color: #0000ff">="Dynamic"</span><span style="color: #0000ff">></</span><span style="color: #800000">asp:RequiredFieldValidator</span><span style="color: #0000ff">></span></pre>
<!--CRLF-->
<pre style="border-top-style: none; overflow: visible; font-size: 8pt; border-left-style: none; font-family: 'Courier New', courier, monospace; border-bottom-style: none; color: black; padding-bottom: 0px; direction: ltr; text-align: left; padding-top: 0px; border-right-style: none; padding-left: 0px; margin: 0em; line-height: 12pt; padding-right: 0px; width: 100%; background-color: white"><span id="lnum23" style="color: #606060"> 23:</span> <span style="color: #0000ff"><</span><span style="color: #800000">asp:RegularExpressionValidator</span> <span style="color: #ff0000">runat</span><span style="color: #0000ff">="server"</span> <span style="color: #ff0000">ValidationExpression</span><span style="color: #0000ff">="\d*"</span> <span style="color: #ff0000">ErrorMessage</span><span style="color: #0000ff">="Felaktigt telefonnummer"</span> <span style="color: #ff0000">ControlToValidate</span><span style="color: #0000ff">="txtPhone"</span> <span style="color: #ff0000">Display</span><span style="color: #0000ff">="Dynamic"</span> <span style="color: #ff0000">ValidationGroup</span><span style="color: #0000ff">="form"</span><span style="color: #0000ff">></</span><span style="color: #800000">asp:RegularExpressionValidator</span><span style="color: #0000ff">></span></pre>
<!--CRLF-->
<pre style="border-top-style: none; overflow: visible; font-size: 8pt; border-left-style: none; font-family: 'Courier New', courier, monospace; border-bottom-style: none; color: black; padding-bottom: 0px; direction: ltr; text-align: left; padding-top: 0px; border-right-style: none; padding-left: 0px; margin: 0em; line-height: 12pt; padding-right: 0px; width: 100%; background-color: #f4f4f4"><span id="lnum24" style="color: #606060"> 24:</span>  </pre>
<!--CRLF-->
<pre style="border-top-style: none; overflow: visible; font-size: 8pt; border-left-style: none; font-family: 'Courier New', courier, monospace; border-bottom-style: none; color: black; padding-bottom: 0px; direction: ltr; text-align: left; padding-top: 0px; border-right-style: none; padding-left: 0px; margin: 0em; line-height: 12pt; padding-right: 0px; width: 100%; background-color: white"><span id="lnum25" style="color: #606060"> 25:</span> <span style="color: #0000ff"></</span><span style="color: #800000">div</span><span style="color: #0000ff">></span></pre>
<!--CRLF-->
<pre style="border-top-style: none; overflow: visible; font-size: 8pt; border-left-style: none; font-family: 'Courier New', courier, monospace; border-bottom-style: none; color: black; padding-bottom: 0px; direction: ltr; text-align: left; padding-top: 0px; border-right-style: none; padding-left: 0px; margin: 0em; line-height: 12pt; padding-right: 0px; width: 100%; background-color: #f4f4f4"><span id="lnum26" style="color: #606060"> 26:</span> <span style="color: #0000ff"><</span><span style="color: #800000">div</span> <span style="color: #ff0000">class</span><span style="color: #0000ff">="input input-message"</span><span style="color: #0000ff">></span></pre>
<!--CRLF-->
<pre style="border-top-style: none; overflow: visible; font-size: 8pt; border-left-style: none; font-family: 'Courier New', courier, monospace; border-bottom-style: none; color: black; padding-bottom: 0px; direction: ltr; text-align: left; padding-top: 0px; border-right-style: none; padding-left: 0px; margin: 0em; line-height: 12pt; padding-right: 0px; width: 100%; background-color: white"><span id="lnum27" style="color: #606060"> 27:</span> <span style="color: #0000ff"><</span><span style="color: #800000">asp:Label</span> <span style="color: #ff0000">runat</span><span style="color: #0000ff">="server"</span> <span style="color: #ff0000">ID</span><span style="color: #0000ff">="Label4"</span> <span style="color: #ff0000">AssociatedControlID</span><span style="color: #0000ff">="txtMessage"</span><span style="color: #0000ff">></span>Meddelande:<span style="color: #0000ff"></</span><span style="color: #800000">asp:Label</span><span style="color: #0000ff">></span></pre>
<!--CRLF-->
<pre style="border-top-style: none; overflow: visible; font-size: 8pt; border-left-style: none; font-family: 'Courier New', courier, monospace; border-bottom-style: none; color: black; padding-bottom: 0px; direction: ltr; text-align: left; padding-top: 0px; border-right-style: none; padding-left: 0px; margin: 0em; line-height: 12pt; padding-right: 0px; width: 100%; background-color: #f4f4f4"><span id="lnum28" style="color: #606060"> 28:</span> <span style="color: #0000ff"><</span><span style="color: #800000">asp:TextBox</span> <span style="color: #ff0000">runat</span><span style="color: #0000ff">="server"</span> <span style="color: #ff0000">ID</span><span style="color: #0000ff">="txtMessage"</span> <span style="color: #ff0000">TextMode</span><span style="color: #0000ff">="MultiLine"</span> <span style="color: #ff0000">ValidationGroup</span><span style="color: #0000ff">="form"</span><span style="color: #0000ff">></</span><span style="color: #800000">asp:TextBox</span><span style="color: #0000ff">></span></pre>
<!--CRLF-->
<pre style="border-top-style: none; overflow: visible; font-size: 8pt; border-left-style: none; font-family: 'Courier New', courier, monospace; border-bottom-style: none; color: black; padding-bottom: 0px; direction: ltr; text-align: left; padding-top: 0px; border-right-style: none; padding-left: 0px; margin: 0em; line-height: 12pt; padding-right: 0px; width: 100%; background-color: white"><span id="lnum29" style="color: #606060"> 29:</span> <span style="color: #0000ff"></</span><span style="color: #800000">div</span><span style="color: #0000ff">></span></pre>
<!--CRLF-->
<pre style="border-top-style: none; overflow: visible; font-size: 8pt; border-left-style: none; font-family: 'Courier New', courier, monospace; border-bottom-style: none; color: black; padding-bottom: 0px; direction: ltr; text-align: left; padding-top: 0px; border-right-style: none; padding-left: 0px; margin: 0em; line-height: 12pt; padding-right: 0px; width: 100%; background-color: #f4f4f4"><span id="lnum30" style="color: #606060"> 30:</span> <span style="color: #0000ff"></</span><span style="color: #800000">div</span><span style="color: #0000ff">></span></pre>
<!--CRLF-->
<pre style="border-top-style: none; overflow: visible; font-size: 8pt; border-left-style: none; font-family: 'Courier New', courier, monospace; border-bottom-style: none; color: black; padding-bottom: 0px; direction: ltr; text-align: left; padding-top: 0px; border-right-style: none; padding-left: 0px; margin: 0em; line-height: 12pt; padding-right: 0px; width: 100%; background-color: white"><span id="lnum31" style="color: #606060"> 31:</span> <span style="color: #0000ff"><</span><span style="color: #800000">div</span> <span style="color: #ff0000">class</span><span style="color: #0000ff">="clearfix"</span><span style="color: #0000ff">></</span><span style="color: #800000">div</span><span style="color: #0000ff">></span></pre>
<!--CRLF-->
<pre style="border-top-style: none; overflow: visible; font-size: 8pt; border-left-style: none; font-family: 'Courier New', courier, monospace; border-bottom-style: none; color: black; padding-bottom: 0px; direction: ltr; text-align: left; padding-top: 0px; border-right-style: none; padding-left: 0px; margin: 0em; line-height: 12pt; padding-right: 0px; width: 100%; background-color: #f4f4f4"><span id="lnum32" style="color: #606060"> 32:</span> <span style="color: #0000ff"><</span><span style="color: #800000">div</span> <span style="color: #ff0000">class</span><span style="color: #0000ff">="check"</span><span style="color: #0000ff">></span></pre>
<!--CRLF-->
<pre style="border-top-style: none; overflow: visible; font-size: 8pt; border-left-style: none; font-family: 'Courier New', courier, monospace; border-bottom-style: none; color: black; padding-bottom: 0px; direction: ltr; text-align: left; padding-top: 0px; border-right-style: none; padding-left: 0px; margin: 0em; line-height: 12pt; padding-right: 0px; width: 100%; background-color: white"><span id="lnum33" style="color: #606060"> 33:</span>  </pre>
<!--CRLF-->
<pre style="border-top-style: none; overflow: visible; font-size: 8pt; border-left-style: none; font-family: 'Courier New', courier, monospace; border-bottom-style: none; color: black; padding-bottom: 0px; direction: ltr; text-align: left; padding-top: 0px; border-right-style: none; padding-left: 0px; margin: 0em; line-height: 12pt; padding-right: 0px; width: 100%; background-color: #f4f4f4"><span id="lnum34" style="color: #606060"> 34:</span> <span style="color: #0000ff"><</span><span style="color: #800000">label</span><span style="color: #0000ff">></span></pre>
<!--CRLF-->
<pre style="border-top-style: none; overflow: visible; font-size: 8pt; border-left-style: none; font-family: 'Courier New', courier, monospace; border-bottom-style: none; color: black; padding-bottom: 0px; direction: ltr; text-align: left; padding-top: 0px; border-right-style: none; padding-left: 0px; margin: 0em; line-height: 12pt; padding-right: 0px; width: 100%; background-color: white"><span id="lnum35" style="color: #606060"> 35:</span> <span style="color: #0000ff"><</span><span style="color: #800000">asp:CheckBox</span> <span style="color: #ff0000">runat</span><span style="color: #0000ff">="server"</span> <span style="color: #ff0000">ID</span><span style="color: #0000ff">="chkConfirm"</span> <span style="color: #ff0000">ValidationGroup</span><span style="color: #0000ff">="form"</span> <span style="color: #0000ff">/></span></pre>
<!--CRLF-->
<pre style="border-top-style: none; overflow: visible; font-size: 8pt; border-left-style: none; font-family: 'Courier New', courier, monospace; border-bottom-style: none; color: black; padding-bottom: 0px; direction: ltr; text-align: left; padding-top: 0px; border-right-style: none; padding-left: 0px; margin: 0em; line-height: 12pt; padding-right: 0px; width: 100%; background-color: #f4f4f4"><span id="lnum36" style="color: #606060"> 36:</span> <span style="color: #0000ff"><</span><span style="color: #800000">span</span><span style="color: #0000ff">></span>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Donec nec hendrerit dolor. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Duis in est diam, et bibendum mi. Donec molestie nibh sit.<span style="color: #0000ff"></</span><span style="color: #800000">span</span><span style="color: #0000ff">></span></pre>
<!--CRLF-->
<pre style="border-top-style: none; overflow: visible; font-size: 8pt; border-left-style: none; font-family: 'Courier New', courier, monospace; border-bottom-style: none; color: black; padding-bottom: 0px; direction: ltr; text-align: left; padding-top: 0px; border-right-style: none; padding-left: 0px; margin: 0em; line-height: 12pt; padding-right: 0px; width: 100%; background-color: white"><span id="lnum37" style="color: #606060"> 37:</span>  </pre>
<!--CRLF-->
<pre style="border-top-style: none; overflow: visible; font-size: 8pt; border-left-style: none; font-family: 'Courier New', courier, monospace; border-bottom-style: none; color: black; padding-bottom: 0px; direction: ltr; text-align: left; padding-top: 0px; border-right-style: none; padding-left: 0px; margin: 0em; line-height: 12pt; padding-right: 0px; width: 100%; background-color: #f4f4f4"><span id="lnum38" style="color: #606060"> 38:</span>  </pre>
<!--CRLF-->
<pre style="border-top-style: none; overflow: visible; font-size: 8pt; border-left-style: none; font-family: 'Courier New', courier, monospace; border-bottom-style: none; color: black; padding-bottom: 0px; direction: ltr; text-align: left; padding-top: 0px; border-right-style: none; padding-left: 0px; margin: 0em; line-height: 12pt; padding-right: 0px; width: 100%; background-color: white"><span id="lnum39" style="color: #606060"> 39:</span> <span style="color: #0000ff"></</span><span style="color: #800000">label</span><span style="color: #0000ff">></span></pre>
<!--CRLF-->
<pre style="border-top-style: none; overflow: visible; font-size: 8pt; border-left-style: none; font-family: 'Courier New', courier, monospace; border-bottom-style: none; color: black; padding-bottom: 0px; direction: ltr; text-align: left; padding-top: 0px; border-right-style: none; padding-left: 0px; margin: 0em; line-height: 12pt; padding-right: 0px; width: 100%; background-color: #f4f4f4"><span id="lnum40" style="color: #606060"> 40:</span> <span style="color: #0000ff"><</span><span style="color: #800000">asp:CustomValidator</span> <span style="color: #ff0000">ID</span><span style="color: #0000ff">="CustomValidator1"</span> <span style="color: #ff0000">runat</span><span style="color: #0000ff">="server"</span> <span style="color: #ff0000">OnServerValidate</span><span style="color: #0000ff">="ValidateCheckbox"</span> <span style="color: #ff0000">EnableClientScript</span><span style="color: #0000ff">="True"</span> <span style="color: #ff0000">Display</span><span style="color: #0000ff">="Dynamic"</span> <span style="color: #ff0000">ValidationGroup</span><span style="color: #0000ff">="form"</span><span style="color: #0000ff">></span>Du måste godkänna att vi kontaktar dig.<span style="color: #0000ff"></</span><span style="color: #800000">asp:CustomValidator</span><span style="color: #0000ff">></span></pre>
<!--CRLF-->
<pre style="border-top-style: none; overflow: visible; font-size: 8pt; border-left-style: none; font-family: 'Courier New', courier, monospace; border-bottom-style: none; color: black; padding-bottom: 0px; direction: ltr; text-align: left; padding-top: 0px; border-right-style: none; padding-left: 0px; margin: 0em; line-height: 12pt; padding-right: 0px; width: 100%; background-color: white"><span id="lnum41" style="color: #606060"> 41:</span> <span style="color: #0000ff"></</span><span style="color: #800000">div</span><span style="color: #0000ff">></span></pre>
<!--CRLF-->
<pre style="border-top-style: none; overflow: visible; font-size: 8pt; border-left-style: none; font-family: 'Courier New', courier, monospace; border-bottom-style: none; color: black; padding-bottom: 0px; direction: ltr; text-align: left; padding-top: 0px; border-right-style: none; padding-left: 0px; margin: 0em; line-height: 12pt; padding-right: 0px; width: 100%; background-color: #f4f4f4"><span id="lnum42" style="color: #606060"> 42:</span> <span style="color: #0000ff"><</span><span style="color: #800000">div</span> <span style="color: #ff0000">class</span><span style="color: #0000ff">="submit"</span><span style="color: #0000ff">></span></pre>
<!--CRLF-->
<pre style="border-top-style: none; overflow: visible; font-size: 8pt; border-left-style: none; font-family: 'Courier New', courier, monospace; border-bottom-style: none; color: black; padding-bottom: 0px; direction: ltr; text-align: left; padding-top: 0px; border-right-style: none; padding-left: 0px; margin: 0em; line-height: 12pt; padding-right: 0px; width: 100%; background-color: white"><span id="lnum43" style="color: #606060"> 43:</span> <span style="color: #0000ff"><</span><span style="color: #800000">asp:ImageButton</span> <span style="color: #ff0000">runat</span><span style="color: #0000ff">="server"</span> <span style="color: #ff0000">ID</span><span style="color: #0000ff">="btnSubmit"</span> <span style="color: #ff0000">ImageUrl</span><span style="color: #0000ff">="~/images/foretag/form-skicka.png"</span> <span style="color: #ff0000">PostBackUrl</span><span style="color: #0000ff">="#contact"</span> <span style="color: #ff0000">ValidationGroup</span><span style="color: #0000ff">="form"</span> <span style="color: #0000ff">/></span></pre>
<!--CRLF-->
<pre style="border-top-style: none; overflow: visible; font-size: 8pt; border-left-style: none; font-family: 'Courier New', courier, monospace; border-bottom-style: none; color: black; padding-bottom: 0px; direction: ltr; text-align: left; padding-top: 0px; border-right-style: none; padding-left: 0px; margin: 0em; line-height: 12pt; padding-right: 0px; width: 100%; background-color: #f4f4f4"><span id="lnum44" style="color: #606060"> 44:</span> <span style="color: #0000ff"></</span><span style="color: #800000">div</span><span style="color: #0000ff">></span></pre>
<!--CRLF-->
<pre style="border-top-style: none; overflow: visible; font-size: 8pt; border-left-style: none; font-family: 'Courier New', courier, monospace; border-bottom-style: none; color: black; padding-bottom: 0px; direction: ltr; text-align: left; padding-top: 0px; border-right-style: none; padding-left: 0px; margin: 0em; line-height: 12pt; padding-right: 0px; width: 100%; background-color: white"><span id="lnum45" style="color: #606060"> 45:</span> <span style="color: #0000ff"></</span><span style="color: #800000">div</span><span style="color: #0000ff">></span></pre>
<!--CRLF--></div>
</div>
<p> </p>
<p>The rest is code behind and it is really simple:</p>
<div id="codeSnippetWrapper" style="overflow: auto; cursor: text; font-size: 8pt; border-top: silver 1px solid; font-family: 'Courier New', courier, monospace; border-right: silver 1px solid; border-bottom: silver 1px solid; padding-bottom: 4px; direction: ltr; text-align: left; padding-top: 4px; padding-left: 4px; margin: 20px 0px 10px; border-left: silver 1px solid; line-height: 12pt; padding-right: 4px; max-height: 200px; width: 97.5%; background-color: #f4f4f4">
<div id="codeSnippet" style="border-top-style: none; overflow: visible; font-size: 8pt; border-left-style: none; font-family: 'Courier New', courier, monospace; border-bottom-style: none; color: black; padding-bottom: 0px; direction: ltr; text-align: left; padding-top: 0px; border-right-style: none; padding-left: 0px; line-height: 12pt; padding-right: 0px; width: 100%; background-color: #f4f4f4">
<pre style="border-top-style: none; overflow: visible; font-size: 8pt; border-left-style: none; font-family: 'Courier New', courier, monospace; border-bottom-style: none; color: black; padding-bottom: 0px; direction: ltr; text-align: left; padding-top: 0px; border-right-style: none; padding-left: 0px; margin: 0em; line-height: 12pt; padding-right: 0px; width: 100%; background-color: white"><span id="lnum1" style="color: #606060"> 1:</span> <span style="color: #0000ff">if</span> (CurrentPage[<span style="color: #006080">"Form"</span>] != <span style="color: #0000ff">null</span> && Page.IsValid)</pre>
<!--CRLF-->
<pre style="border-top-style: none; overflow: visible; font-size: 8pt; border-left-style: none; font-family: 'Courier New', courier, monospace; border-bottom-style: none; color: black; padding-bottom: 0px; direction: ltr; text-align: left; padding-top: 0px; border-right-style: none; padding-left: 0px; margin: 0em; line-height: 12pt; padding-right: 0px; width: 100%; background-color: #f4f4f4"><span id="lnum2" style="color: #606060"> 2:</span> {</pre>
<!--CRLF-->
<pre style="border-top-style: none; overflow: visible; font-size: 8pt; border-left-style: none; font-family: 'Courier New', courier, monospace; border-bottom-style: none; color: black; padding-bottom: 0px; direction: ltr; text-align: left; padding-top: 0px; border-right-style: none; padding-left: 0px; margin: 0em; line-height: 12pt; padding-right: 0px; width: 100%; background-color: white"><span id="lnum3" style="color: #606060"> 3:</span> <span style="color: #0000ff">string</span> xformprop = CurrentPage[<span style="color: #006080">"Form"</span>] <span style="color: #0000ff">as</span> <span style="color: #0000ff">string</span>;</pre>
<!--CRLF-->
<pre style="border-top-style: none; overflow: visible; font-size: 8pt; border-left-style: none; font-family: 'Courier New', courier, monospace; border-bottom-style: none; color: black; padding-bottom: 0px; direction: ltr; text-align: left; padding-top: 0px; border-right-style: none; padding-left: 0px; margin: 0em; line-height: 12pt; padding-right: 0px; width: 100%; background-color: #f4f4f4"><span id="lnum4" style="color: #606060"> 4:</span> XForm form = XForm.CreateInstance(<span style="color: #0000ff">new</span> Guid(xformprop));</pre>
<!--CRLF-->
<pre style="border-top-style: none; overflow: visible; font-size: 8pt; border-left-style: none; font-family: 'Courier New', courier, monospace; border-bottom-style: none; color: black; padding-bottom: 0px; direction: ltr; text-align: left; padding-top: 0px; border-right-style: none; padding-left: 0px; margin: 0em; line-height: 12pt; padding-right: 0px; width: 100%; background-color: white"><span id="lnum5" style="color: #606060"> 5:</span>  </pre>
<!--CRLF-->
<pre style="border-top-style: none; overflow: visible; font-size: 8pt; border-left-style: none; font-family: 'Courier New', courier, monospace; border-bottom-style: none; color: black; padding-bottom: 0px; direction: ltr; text-align: left; padding-top: 0px; border-right-style: none; padding-left: 0px; margin: 0em; line-height: 12pt; padding-right: 0px; width: 100%; background-color: #f4f4f4"><span id="lnum6" style="color: #606060"> 6:</span> XFormData formData = form.CreateFormData();</pre>
<!--CRLF-->
<pre style="border-top-style: none; overflow: visible; font-size: 8pt; border-left-style: none; font-family: 'Courier New', courier, monospace; border-bottom-style: none; color: black; padding-bottom: 0px; direction: ltr; text-align: left; padding-top: 0px; border-right-style: none; padding-left: 0px; margin: 0em; line-height: 12pt; padding-right: 0px; width: 100%; background-color: white"><span id="lnum7" style="color: #606060"> 7:</span>  </pre>
<!--CRLF-->
<pre style="border-top-style: none; overflow: visible; font-size: 8pt; border-left-style: none; font-family: 'Courier New', courier, monospace; border-bottom-style: none; color: black; padding-bottom: 0px; direction: ltr; text-align: left; padding-top: 0px; border-right-style: none; padding-left: 0px; margin: 0em; line-height: 12pt; padding-right: 0px; width: 100%; background-color: #f4f4f4"><span id="lnum8" style="color: #606060"> 8:</span> formData.PageGuid = CurrentPage.PageGuid;</pre>
<!--CRLF-->
<pre style="border-top-style: none; overflow: visible; font-size: 8pt; border-left-style: none; font-family: 'Courier New', courier, monospace; border-bottom-style: none; color: black; padding-bottom: 0px; direction: ltr; text-align: left; padding-top: 0px; border-right-style: none; padding-left: 0px; margin: 0em; line-height: 12pt; padding-right: 0px; width: 100%; background-color: white"><span id="lnum9" style="color: #606060"> 9:</span> formData.ChannelOptions = ChannelOptions.Database;</pre>
<!--CRLF-->
<pre style="border-top-style: none; overflow: visible; font-size: 8pt; border-left-style: none; font-family: 'Courier New', courier, monospace; border-bottom-style: none; color: black; padding-bottom: 0px; direction: ltr; text-align: left; padding-top: 0px; border-right-style: none; padding-left: 0px; margin: 0em; line-height: 12pt; padding-right: 0px; width: 100%; background-color: #f4f4f4"><span id="lnum10" style="color: #606060"> 10:</span>  </pre>
<!--CRLF-->
<pre style="border-top-style: none; overflow: visible; font-size: 8pt; border-left-style: none; font-family: 'Courier New', courier, monospace; border-bottom-style: none; color: black; padding-bottom: 0px; direction: ltr; text-align: left; padding-top: 0px; border-right-style: none; padding-left: 0px; margin: 0em; line-height: 12pt; padding-right: 0px; width: 100%; background-color: white"><span id="lnum11" style="color: #606060"> 11:</span> <span style="color: #008000">//Set values to form</span></pre>
<!--CRLF-->
<pre style="border-top-style: none; overflow: visible; font-size: 8pt; border-left-style: none; font-family: 'Courier New', courier, monospace; border-bottom-style: none; color: black; padding-bottom: 0px; direction: ltr; text-align: left; padding-top: 0px; border-right-style: none; padding-left: 0px; margin: 0em; line-height: 12pt; padding-right: 0px; width: 100%; background-color: #f4f4f4"><span id="lnum12" style="color: #606060"> 12:</span>  </pre>
<!--CRLF-->
<pre style="border-top-style: none; overflow: visible; font-size: 8pt; border-left-style: none; font-family: 'Courier New', courier, monospace; border-bottom-style: none; color: black; padding-bottom: 0px; direction: ltr; text-align: left; padding-top: 0px; border-right-style: none; padding-left: 0px; margin: 0em; line-height: 12pt; padding-right: 0px; width: 100%; background-color: white"><span id="lnum13" style="color: #606060"> 13:</span> formData.SetValue(<span style="color: #006080">"Namn"</span>, txtName.Text);</pre>
<!--CRLF-->
<pre style="border-top-style: none; overflow: visible; font-size: 8pt; border-left-style: none; font-family: 'Courier New', courier, monospace; border-bottom-style: none; color: black; padding-bottom: 0px; direction: ltr; text-align: left; padding-top: 0px; border-right-style: none; padding-left: 0px; margin: 0em; line-height: 12pt; padding-right: 0px; width: 100%; background-color: #f4f4f4"><span id="lnum14" style="color: #606060"> 14:</span> formData.SetValue(<span style="color: #006080">"E-post"</span>, txtMail.Text);</pre>
<!--CRLF-->
<pre style="border-top-style: none; overflow: visible; font-size: 8pt; border-left-style: none; font-family: 'Courier New', courier, monospace; border-bottom-style: none; color: black; padding-bottom: 0px; direction: ltr; text-align: left; padding-top: 0px; border-right-style: none; padding-left: 0px; margin: 0em; line-height: 12pt; padding-right: 0px; width: 100%; background-color: white"><span id="lnum15" style="color: #606060"> 15:</span> formData.SetValue(<span style="color: #006080">"Företag"</span>, txtCompany.Text);</pre>
<!--CRLF-->
<pre style="border-top-style: none; overflow: visible; font-size: 8pt; border-left-style: none; font-family: 'Courier New', courier, monospace; border-bottom-style: none; color: black; padding-bottom: 0px; direction: ltr; text-align: left; padding-top: 0px; border-right-style: none; padding-left: 0px; margin: 0em; line-height: 12pt; padding-right: 0px; width: 100%; background-color: #f4f4f4"><span id="lnum16" style="color: #606060"> 16:</span> formData.SetValue(<span style="color: #006080">"Telefonnummer"</span>, txtPhone.Text);</pre>
<!--CRLF-->
<pre style="border-top-style: none; overflow: visible; font-size: 8pt; border-left-style: none; font-family: 'Courier New', courier, monospace; border-bottom-style: none; color: black; padding-bottom: 0px; direction: ltr; text-align: left; padding-top: 0px; border-right-style: none; padding-left: 0px; margin: 0em; line-height: 12pt; padding-right: 0px; width: 100%; background-color: white"><span id="lnum17" style="color: #606060"> 17:</span> formData.SetValue(<span style="color: #006080">"Meddelande"</span>, txtMessage.Text);</pre>
<!--CRLF-->
<pre style="border-top-style: none; overflow: visible; font-size: 8pt; border-left-style: none; font-family: 'Courier New', courier, monospace; border-bottom-style: none; color: black; padding-bottom: 0px; direction: ltr; text-align: left; padding-top: 0px; border-right-style: none; padding-left: 0px; margin: 0em; line-height: 12pt; padding-right: 0px; width: 100%; background-color: #f4f4f4"><span id="lnum18" style="color: #606060"> 18:</span> formData.SetValue(<span style="color: #006080">"Godkänd"</span>, chkConfirm.Checked.ToString());</pre>
<!--CRLF-->
<pre style="border-top-style: none; overflow: visible; font-size: 8pt; border-left-style: none; font-family: 'Courier New', courier, monospace; border-bottom-style: none; color: black; padding-bottom: 0px; direction: ltr; text-align: left; padding-top: 0px; border-right-style: none; padding-left: 0px; margin: 0em; line-height: 12pt; padding-right: 0px; width: 100%; background-color: white"><span id="lnum19" style="color: #606060"> 19:</span>  </pre>
<!--CRLF-->
<pre style="border-top-style: none; overflow: visible; font-size: 8pt; border-left-style: none; font-family: 'Courier New', courier, monospace; border-bottom-style: none; color: black; padding-bottom: 0px; direction: ltr; text-align: left; padding-top: 0px; border-right-style: none; padding-left: 0px; margin: 0em; line-height: 12pt; padding-right: 0px; width: 100%; background-color: #f4f4f4"><span id="lnum20" style="color: #606060"> 20:</span>  </pre>
<!--CRLF-->
<pre style="border-top-style: none; overflow: visible; font-size: 8pt; border-left-style: none; font-family: 'Courier New', courier, monospace; border-bottom-style: none; color: black; padding-bottom: 0px; direction: ltr; text-align: left; padding-top: 0px; border-right-style: none; padding-left: 0px; margin: 0em; line-height: 12pt; padding-right: 0px; width: 100%; background-color: white"><span id="lnum21" style="color: #606060"> 21:</span> <span style="color: #008000">//Save form data to form</span></pre>
<!--CRLF-->
<pre style="border-top-style: none; overflow: visible; font-size: 8pt; border-left-style: none; font-family: 'Courier New', courier, monospace; border-bottom-style: none; color: black; padding-bottom: 0px; direction: ltr; text-align: left; padding-top: 0px; border-right-style: none; padding-left: 0px; margin: 0em; line-height: 12pt; padding-right: 0px; width: 100%; background-color: #f4f4f4"><span id="lnum22" style="color: #606060"> 22:</span> formData.Send();</pre>
<!--CRLF-->
<pre style="border-top-style: none; overflow: visible; font-size: 8pt; border-left-style: none; font-family: 'Courier New', courier, monospace; border-bottom-style: none; color: black; padding-bottom: 0px; direction: ltr; text-align: left; padding-top: 0px; border-right-style: none; padding-left: 0px; margin: 0em; line-height: 12pt; padding-right: 0px; width: 100%; background-color: white"><span id="lnum23" style="color: #606060"> 23:</span> }</pre>
<!--CRLF--></div>
</div>
<p>Really nice and easy when you like to store information within a form. Of course you could have use DDS or something like that but since the xform functionality will give the editor control and the capability to export data from the form I think this is ok to use.</p>
<p>In EPiServer CMS 6 the data storage of Xforms and Xform postings is moved to DDS so you could extend your code with searching in forms for instance. You can read more about xforms and dynamic data store in this blogpost by Linus Ekström: <a title="http://world.episerver.com/Blogs/Linus-Ekstrom/Dates/2010/7/Using-the-dynamic-data-store-with-XForms/" href="http://world.episerver.com/Blogs/Linus-Ekstrom/Dates/2010/7/Using-the-dynamic-data-store-with-XForms/">http://world.episerver.com/Blogs/Linus-Ekstrom/Dates/2010/7/Using-the-dynamic-data-store-with-XForms/</a></p>
<p> </p>
<p>Happy Easter!!</p>
Let the Editor translate the site using a page in EPiServer CMS instead of using external resources
/blogs/Eric-Pettersson/Dates/2013/3/Let-the-Editor-translate-the-site-using-a-page-in-EPiServer-CMS-instead-of-using-external-resources/
2013-03-14T17:02:56.0000000Z
<p>In my last blog post, <a title="http://world.episerver.com/Blogs/Eric-Pettersson/Dates/2013/2/Example-of-baseclass-and-access-to-StartPage-in-your-CMS-7-projects/" href="http://world.episerver.com/Blogs/Eric-Pettersson/Dates/2013/2/Example-of-baseclass-and-access-to-StartPage-in-your-CMS-7-projects/">http://world.episerver.com/Blogs/Eric-Pettersson/Dates/2013/2/Example-of-baseclass-and-access-to-StartPage-in-your-CMS-7-projects/</a>, I explained how you can access the startpage as strongly typed so that you can access the user defined properties on startpage on any pagetemplate. In this blog post I will try to explain how you can use a page in EPiServer CMS to translate your text in code instead of using a external resource like the good old languange files in EPiServer.</p> <p>When using a page, instead of xml-files, we can give the responsibility of translating the website to the editor. Most of the time we work with xml-resources and therefore we, developers, are responsible for translating the website. This will cost the customer much more when the like to globalize the website. A solution to this is to use a page in EPiServer CMS and let the editor globalize the page in any language they like.</p> <p>Since this is not my own idea I will give credit to the one that came up with the idea, Mattias Olsson from CGI – Gävle. Thank you very much for beeing an awsome developer! Since then I have used this in all my projects instead of using the xml-files. </p> <h2>Create a new PageReference and PageType</h2> <p>We extend the StartPageType with a new property of type PageReference and add a new pagetype, TranslatePage.</p> <h3>Code startpage:</h3> <p>Create a public PageData object of type TranslatePage using the new Get<>.</p> <div id="codeSnippetWrapper" style="overflow: auto; cursor: text; font-size: 8pt; border-top: silver 1px solid; font-family: 'Courier New', courier, monospace; border-right: silver 1px solid; border-bottom: silver 1px solid; padding-bottom: 4px; direction: ltr; text-align: left; padding-top: 4px; padding-left: 4px; margin: 20px 0px 10px; border-left: silver 1px solid; line-height: 12pt; padding-right: 4px; max-height: 200px; width: 97.5%; background-color: #f4f4f4"> <div id="codeSnippet" style="border-top-style: none; overflow: visible; font-size: 8pt; border-left-style: none; font-family: 'Courier New', courier, monospace; border-bottom-style: none; color: black; padding-bottom: 0px; direction: ltr; text-align: left; padding-top: 0px; border-right-style: none; padding-left: 0px; line-height: 12pt; padding-right: 0px; width: 100%; background-color: #f4f4f4"> <pre style="border-top-style: none; overflow: visible; font-size: 8pt; border-left-style: none; font-family: 'Courier New', courier, monospace; border-bottom-style: none; color: black; padding-bottom: 0px; direction: ltr; text-align: left; padding-top: 0px; border-right-style: none; padding-left: 0px; margin: 0em; line-height: 12pt; padding-right: 0px; width: 100%; background-color: white"><span id="lnum1" style="color: #606060"> 1:</span> <span style="color: #0000ff">private</span> TranslatePage mTranslatePage;</pre>
<!--CRLF-->
<pre style="border-top-style: none; overflow: visible; font-size: 8pt; border-left-style: none; font-family: 'Courier New', courier, monospace; border-bottom-style: none; color: black; padding-bottom: 0px; direction: ltr; text-align: left; padding-top: 0px; border-right-style: none; padding-left: 0px; margin: 0em; line-height: 12pt; padding-right: 0px; width: 100%; background-color: #f4f4f4"><span id="lnum2" style="color: #606060"> 2:</span> <span style="color: #008000">/// <summary></span></pre>
<!--CRLF-->
<pre style="border-top-style: none; overflow: visible; font-size: 8pt; border-left-style: none; font-family: 'Courier New', courier, monospace; border-bottom-style: none; color: black; padding-bottom: 0px; direction: ltr; text-align: left; padding-top: 0px; border-right-style: none; padding-left: 0px; margin: 0em; line-height: 12pt; padding-right: 0px; width: 100%; background-color: white"><span id="lnum3" style="color: #606060"> 3:</span> <span style="color: #008000">/// Global translation page for the web site. Used instead of language xml files.</span></pre>
<!--CRLF-->
<pre style="border-top-style: none; overflow: visible; font-size: 8pt; border-left-style: none; font-family: 'Courier New', courier, monospace; border-bottom-style: none; color: black; padding-bottom: 0px; direction: ltr; text-align: left; padding-top: 0px; border-right-style: none; padding-left: 0px; margin: 0em; line-height: 12pt; padding-right: 0px; width: 100%; background-color: #f4f4f4"><span id="lnum4" style="color: #606060"> 4:</span> <span style="color: #008000">/// </summary></span></pre>
<!--CRLF-->
<pre style="border-top-style: none; overflow: visible; font-size: 8pt; border-left-style: none; font-family: 'Courier New', courier, monospace; border-bottom-style: none; color: black; padding-bottom: 0px; direction: ltr; text-align: left; padding-top: 0px; border-right-style: none; padding-left: 0px; margin: 0em; line-height: 12pt; padding-right: 0px; width: 100%; background-color: white"><span id="lnum5" style="color: #606060"> 5:</span> <span style="color: #0000ff">public</span> TranslatePage TranslationPage</pre>
<!--CRLF-->
<pre style="border-top-style: none; overflow: visible; font-size: 8pt; border-left-style: none; font-family: 'Courier New', courier, monospace; border-bottom-style: none; color: black; padding-bottom: 0px; direction: ltr; text-align: left; padding-top: 0px; border-right-style: none; padding-left: 0px; margin: 0em; line-height: 12pt; padding-right: 0px; width: 100%; background-color: #f4f4f4"><span id="lnum6" style="color: #606060"> 6:</span> {</pre>
<!--CRLF-->
<pre style="border-top-style: none; overflow: visible; font-size: 8pt; border-left-style: none; font-family: 'Courier New', courier, monospace; border-bottom-style: none; color: black; padding-bottom: 0px; direction: ltr; text-align: left; padding-top: 0px; border-right-style: none; padding-left: 0px; margin: 0em; line-height: 12pt; padding-right: 0px; width: 100%; background-color: white"><span id="lnum7" style="color: #606060"> 7:</span> get</pre>
<!--CRLF-->
<pre style="border-top-style: none; overflow: visible; font-size: 8pt; border-left-style: none; font-family: 'Courier New', courier, monospace; border-bottom-style: none; color: black; padding-bottom: 0px; direction: ltr; text-align: left; padding-top: 0px; border-right-style: none; padding-left: 0px; margin: 0em; line-height: 12pt; padding-right: 0px; width: 100%; background-color: #f4f4f4"><span id="lnum8" style="color: #606060"> 8:</span> {</pre>
<!--CRLF-->
<pre style="border-top-style: none; overflow: visible; font-size: 8pt; border-left-style: none; font-family: 'Courier New', courier, monospace; border-bottom-style: none; color: black; padding-bottom: 0px; direction: ltr; text-align: left; padding-top: 0px; border-right-style: none; padding-left: 0px; margin: 0em; line-height: 12pt; padding-right: 0px; width: 100%; background-color: white"><span id="lnum9" style="color: #606060"> 9:</span> <span style="color: #0000ff">if</span> (mTranslatePage == <span style="color: #0000ff">null</span>)</pre>
<!--CRLF-->
<pre style="border-top-style: none; overflow: visible; font-size: 8pt; border-left-style: none; font-family: 'Courier New', courier, monospace; border-bottom-style: none; color: black; padding-bottom: 0px; direction: ltr; text-align: left; padding-top: 0px; border-right-style: none; padding-left: 0px; margin: 0em; line-height: 12pt; padding-right: 0px; width: 100%; background-color: #f4f4f4"><span id="lnum10" style="color: #606060"> 10:</span> {</pre>
<!--CRLF-->
<pre style="border-top-style: none; overflow: visible; font-size: 8pt; border-left-style: none; font-family: 'Courier New', courier, monospace; border-bottom-style: none; color: black; padding-bottom: 0px; direction: ltr; text-align: left; padding-top: 0px; border-right-style: none; padding-left: 0px; margin: 0em; line-height: 12pt; padding-right: 0px; width: 100%; background-color: white"><span id="lnum11" style="color: #606060"> 11:</span> <span style="color: #0000ff">if</span> (!PageReference.IsNullOrEmpty(TranslationPageLink))</pre>
<!--CRLF-->
<pre style="border-top-style: none; overflow: visible; font-size: 8pt; border-left-style: none; font-family: 'Courier New', courier, monospace; border-bottom-style: none; color: black; padding-bottom: 0px; direction: ltr; text-align: left; padding-top: 0px; border-right-style: none; padding-left: 0px; margin: 0em; line-height: 12pt; padding-right: 0px; width: 100%; background-color: #f4f4f4"><span id="lnum12" style="color: #606060"> 12:</span> mTranslatePage = DataFactory.Instance.Get<TranslatePage>(TranslationPageLink);</pre>
<!--CRLF-->
<pre style="border-top-style: none; overflow: visible; font-size: 8pt; border-left-style: none; font-family: 'Courier New', courier, monospace; border-bottom-style: none; color: black; padding-bottom: 0px; direction: ltr; text-align: left; padding-top: 0px; border-right-style: none; padding-left: 0px; margin: 0em; line-height: 12pt; padding-right: 0px; width: 100%; background-color: white"><span id="lnum13" style="color: #606060"> 13:</span> }</pre>
<!--CRLF-->
<pre style="border-top-style: none; overflow: visible; font-size: 8pt; border-left-style: none; font-family: 'Courier New', courier, monospace; border-bottom-style: none; color: black; padding-bottom: 0px; direction: ltr; text-align: left; padding-top: 0px; border-right-style: none; padding-left: 0px; margin: 0em; line-height: 12pt; padding-right: 0px; width: 100%; background-color: #f4f4f4"><span id="lnum14" style="color: #606060"> 14:</span>  </pre>
<!--CRLF-->
<pre style="border-top-style: none; overflow: visible; font-size: 8pt; border-left-style: none; font-family: 'Courier New', courier, monospace; border-bottom-style: none; color: black; padding-bottom: 0px; direction: ltr; text-align: left; padding-top: 0px; border-right-style: none; padding-left: 0px; margin: 0em; line-height: 12pt; padding-right: 0px; width: 100%; background-color: white"><span id="lnum15" style="color: #606060"> 15:</span> <span style="color: #0000ff">return</span> mTranslatePage;</pre>
<!--CRLF-->
<pre style="border-top-style: none; overflow: visible; font-size: 8pt; border-left-style: none; font-family: 'Courier New', courier, monospace; border-bottom-style: none; color: black; padding-bottom: 0px; direction: ltr; text-align: left; padding-top: 0px; border-right-style: none; padding-left: 0px; margin: 0em; line-height: 12pt; padding-right: 0px; width: 100%; background-color: #f4f4f4"><span id="lnum16" style="color: #606060"> 16:</span> }</pre>
<!--CRLF-->
<pre style="border-top-style: none; overflow: visible; font-size: 8pt; border-left-style: none; font-family: 'Courier New', courier, monospace; border-bottom-style: none; color: black; padding-bottom: 0px; direction: ltr; text-align: left; padding-top: 0px; border-right-style: none; padding-left: 0px; margin: 0em; line-height: 12pt; padding-right: 0px; width: 100%; background-color: white"><span id="lnum17" style="color: #606060"> 17:</span> }</pre>
<!--CRLF--></div>
</div>
<h3>Code TranslatePage</h3>
<p>Just an empty definition of a PageType. Add your lables that needs to be translated.</p>
<div id="codeSnippetWrapper" style="overflow: auto; cursor: text; font-size: 8pt; border-top: silver 1px solid; font-family: 'Courier New', courier, monospace; border-right: silver 1px solid; border-bottom: silver 1px solid; padding-bottom: 4px; direction: ltr; text-align: left; padding-top: 4px; padding-left: 4px; margin: 20px 0px 10px; border-left: silver 1px solid; line-height: 12pt; padding-right: 4px; max-height: 200px; width: 97.5%; background-color: #f4f4f4">
<div id="codeSnippet" style="border-top-style: none; overflow: visible; font-size: 8pt; border-left-style: none; font-family: 'Courier New', courier, monospace; border-bottom-style: none; color: black; padding-bottom: 0px; direction: ltr; text-align: left; padding-top: 0px; border-right-style: none; padding-left: 0px; line-height: 12pt; padding-right: 0px; width: 100%; background-color: #f4f4f4">
<pre style="border-top-style: none; overflow: visible; font-size: 8pt; border-left-style: none; font-family: 'Courier New', courier, monospace; border-bottom-style: none; color: black; padding-bottom: 0px; direction: ltr; text-align: left; padding-top: 0px; border-right-style: none; padding-left: 0px; margin: 0em; line-height: 12pt; padding-right: 0px; width: 100%; background-color: white"><span id="lnum1" style="color: #606060"> 1:</span> [ContentType(DisplayName = <span style="color: #006080">"TranslatePage"</span>, GUID = <span style="color: #006080">"f26fe705-780d-4bf0-90fa-66dba465e0a3"</span>, Description = <span style="color: #006080">""</span>)]</pre>
<!--CRLF-->
<pre style="border-top-style: none; overflow: visible; font-size: 8pt; border-left-style: none; font-family: 'Courier New', courier, monospace; border-bottom-style: none; color: black; padding-bottom: 0px; direction: ltr; text-align: left; padding-top: 0px; border-right-style: none; padding-left: 0px; margin: 0em; line-height: 12pt; padding-right: 0px; width: 100%; background-color: #f4f4f4"><span id="lnum2" style="color: #606060"> 2:</span> <span style="color: #0000ff">public</span> <span style="color: #0000ff">class</span> TranslatePage : PageData</pre>
<!--CRLF-->
<pre style="border-top-style: none; overflow: visible; font-size: 8pt; border-left-style: none; font-family: 'Courier New', courier, monospace; border-bottom-style: none; color: black; padding-bottom: 0px; direction: ltr; text-align: left; padding-top: 0px; border-right-style: none; padding-left: 0px; margin: 0em; line-height: 12pt; padding-right: 0px; width: 100%; background-color: white"><span id="lnum3" style="color: #606060"> 3:</span> {</pre>
<!--CRLF-->
<pre style="border-top-style: none; overflow: visible; font-size: 8pt; border-left-style: none; font-family: 'Courier New', courier, monospace; border-bottom-style: none; color: black; padding-bottom: 0px; direction: ltr; text-align: left; padding-top: 0px; border-right-style: none; padding-left: 0px; margin: 0em; line-height: 12pt; padding-right: 0px; width: 100%; background-color: #f4f4f4"><span id="lnum4" style="color: #606060"> 4:</span> </pre>
<!--CRLF-->
<pre style="border-top-style: none; overflow: visible; font-size: 8pt; border-left-style: none; font-family: 'Courier New', courier, monospace; border-bottom-style: none; color: black; padding-bottom: 0px; direction: ltr; text-align: left; padding-top: 0px; border-right-style: none; padding-left: 0px; margin: 0em; line-height: 12pt; padding-right: 0px; width: 100%; background-color: white"><span id="lnum5" style="color: #606060"> 5:</span> }</pre>
<!--CRLF--></div>
</div>
<p> </p>
<p> </p>
<h2>Extend our templates with our own base class</h2>
<p>In your base class for templates we now extend the functionality with the TranslatePage, read my last blogpost for more information: <a title="http://world.episerver.com/Blogs/Eric-Pettersson/Dates/2013/2/Example-of-baseclass-and-access-to-StartPage-in-your-CMS-7-projects/" href="http://world.episerver.com/Blogs/Eric-Pettersson/Dates/2013/2/Example-of-baseclass-and-access-to-StartPage-in-your-CMS-7-projects/">http://world.episerver.com/Blogs/Eric-Pettersson/Dates/2013/2/Example-of-baseclass-and-access-to-StartPage-in-your-CMS-7-projects/</a></p>
<div id="codeSnippetWrapper" style="overflow: auto; cursor: text; font-size: 8pt; border-top: silver 1px solid; font-family: 'Courier New', courier, monospace; border-right: silver 1px solid; border-bottom: silver 1px solid; padding-bottom: 4px; direction: ltr; text-align: left; padding-top: 4px; padding-left: 4px; margin: 20px 0px 10px; border-left: silver 1px solid; line-height: 12pt; padding-right: 4px; max-height: 200px; width: 97.5%; background-color: #f4f4f4">
<div id="codeSnippet" style="border-top-style: none; overflow: visible; font-size: 8pt; border-left-style: none; font-family: 'Courier New', courier, monospace; border-bottom-style: none; color: black; padding-bottom: 0px; direction: ltr; text-align: left; padding-top: 0px; border-right-style: none; padding-left: 0px; line-height: 12pt; padding-right: 0px; width: 100%; background-color: #f4f4f4">
<pre style="border-top-style: none; overflow: visible; font-size: 8pt; border-left-style: none; font-family: 'Courier New', courier, monospace; border-bottom-style: none; color: black; padding-bottom: 0px; direction: ltr; text-align: left; padding-top: 0px; border-right-style: none; padding-left: 0px; margin: 0em; line-height: 12pt; padding-right: 0px; width: 100%; background-color: white"><span id="lnum1" style="color: #606060"> 1:</span> <span style="color: #008000">/// <summary></span></pre>
<!--CRLF-->
<pre style="border-top-style: none; overflow: visible; font-size: 8pt; border-left-style: none; font-family: 'Courier New', courier, monospace; border-bottom-style: none; color: black; padding-bottom: 0px; direction: ltr; text-align: left; padding-top: 0px; border-right-style: none; padding-left: 0px; margin: 0em; line-height: 12pt; padding-right: 0px; width: 100%; background-color: #f4f4f4"><span id="lnum2" style="color: #606060"> 2:</span> <span style="color: #008000">/// Global translation page</span></pre>
<!--CRLF-->
<pre style="border-top-style: none; overflow: visible; font-size: 8pt; border-left-style: none; font-family: 'Courier New', courier, monospace; border-bottom-style: none; color: black; padding-bottom: 0px; direction: ltr; text-align: left; padding-top: 0px; border-right-style: none; padding-left: 0px; margin: 0em; line-height: 12pt; padding-right: 0px; width: 100%; background-color: white"><span id="lnum3" style="color: #606060"> 3:</span> <span style="color: #008000">/// </summary></span></pre>
<!--CRLF-->
<pre style="border-top-style: none; overflow: visible; font-size: 8pt; border-left-style: none; font-family: 'Courier New', courier, monospace; border-bottom-style: none; color: black; padding-bottom: 0px; direction: ltr; text-align: left; padding-top: 0px; border-right-style: none; padding-left: 0px; margin: 0em; line-height: 12pt; padding-right: 0px; width: 100%; background-color: #f4f4f4"><span id="lnum4" style="color: #606060"> 4:</span> <span style="color: #0000ff">public</span> TranslatePage TranslationPage</pre>
<!--CRLF-->
<pre style="border-top-style: none; overflow: visible; font-size: 8pt; border-left-style: none; font-family: 'Courier New', courier, monospace; border-bottom-style: none; color: black; padding-bottom: 0px; direction: ltr; text-align: left; padding-top: 0px; border-right-style: none; padding-left: 0px; margin: 0em; line-height: 12pt; padding-right: 0px; width: 100%; background-color: white"><span id="lnum5" style="color: #606060"> 5:</span> {</pre>
<!--CRLF-->
<pre style="border-top-style: none; overflow: visible; font-size: 8pt; border-left-style: none; font-family: 'Courier New', courier, monospace; border-bottom-style: none; color: black; padding-bottom: 0px; direction: ltr; text-align: left; padding-top: 0px; border-right-style: none; padding-left: 0px; margin: 0em; line-height: 12pt; padding-right: 0px; width: 100%; background-color: #f4f4f4"><span id="lnum6" style="color: #606060"> 6:</span> get</pre>
<!--CRLF-->
<pre style="border-top-style: none; overflow: visible; font-size: 8pt; border-left-style: none; font-family: 'Courier New', courier, monospace; border-bottom-style: none; color: black; padding-bottom: 0px; direction: ltr; text-align: left; padding-top: 0px; border-right-style: none; padding-left: 0px; margin: 0em; line-height: 12pt; padding-right: 0px; width: 100%; background-color: white"><span id="lnum7" style="color: #606060"> 7:</span> {</pre>
<!--CRLF-->
<pre style="border-top-style: none; overflow: visible; font-size: 8pt; border-left-style: none; font-family: 'Courier New', courier, monospace; border-bottom-style: none; color: black; padding-bottom: 0px; direction: ltr; text-align: left; padding-top: 0px; border-right-style: none; padding-left: 0px; margin: 0em; line-height: 12pt; padding-right: 0px; width: 100%; background-color: #f4f4f4"><span id="lnum8" style="color: #606060"> 8:</span> <span style="color: #0000ff">if</span> (StartPage.TranslationPage == <span style="color: #0000ff">null</span>)</pre>
<!--CRLF-->
<pre style="border-top-style: none; overflow: visible; font-size: 8pt; border-left-style: none; font-family: 'Courier New', courier, monospace; border-bottom-style: none; color: black; padding-bottom: 0px; direction: ltr; text-align: left; padding-top: 0px; border-right-style: none; padding-left: 0px; margin: 0em; line-height: 12pt; padding-right: 0px; width: 100%; background-color: white"><span id="lnum9" style="color: #606060"> 9:</span> {</pre>
<!--CRLF-->
<pre style="border-top-style: none; overflow: visible; font-size: 8pt; border-left-style: none; font-family: 'Courier New', courier, monospace; border-bottom-style: none; color: black; padding-bottom: 0px; direction: ltr; text-align: left; padding-top: 0px; border-right-style: none; padding-left: 0px; margin: 0em; line-height: 12pt; padding-right: 0px; width: 100%; background-color: #f4f4f4"><span id="lnum10" style="color: #606060"> 10:</span> <span style="color: #0000ff">throw</span> <span style="color: #0000ff">new</span> EPiServerException(<span style="color: #006080">"Translation page is not defined on start page."</span>);</pre>
<!--CRLF-->
<pre style="border-top-style: none; overflow: visible; font-size: 8pt; border-left-style: none; font-family: 'Courier New', courier, monospace; border-bottom-style: none; color: black; padding-bottom: 0px; direction: ltr; text-align: left; padding-top: 0px; border-right-style: none; padding-left: 0px; margin: 0em; line-height: 12pt; padding-right: 0px; width: 100%; background-color: white"><span id="lnum11" style="color: #606060"> 11:</span> }</pre>
<!--CRLF-->
<pre style="border-top-style: none; overflow: visible; font-size: 8pt; border-left-style: none; font-family: 'Courier New', courier, monospace; border-bottom-style: none; color: black; padding-bottom: 0px; direction: ltr; text-align: left; padding-top: 0px; border-right-style: none; padding-left: 0px; margin: 0em; line-height: 12pt; padding-right: 0px; width: 100%; background-color: #f4f4f4"><span id="lnum12" style="color: #606060"> 12:</span>  </pre>
<!--CRLF-->
<pre style="border-top-style: none; overflow: visible; font-size: 8pt; border-left-style: none; font-family: 'Courier New', courier, monospace; border-bottom-style: none; color: black; padding-bottom: 0px; direction: ltr; text-align: left; padding-top: 0px; border-right-style: none; padding-left: 0px; margin: 0em; line-height: 12pt; padding-right: 0px; width: 100%; background-color: white"><span id="lnum13" style="color: #606060"> 13:</span> <span style="color: #0000ff">return</span> StartPage.TranslationPage;</pre>
<!--CRLF-->
<pre style="border-top-style: none; overflow: visible; font-size: 8pt; border-left-style: none; font-family: 'Courier New', courier, monospace; border-bottom-style: none; color: black; padding-bottom: 0px; direction: ltr; text-align: left; padding-top: 0px; border-right-style: none; padding-left: 0px; margin: 0em; line-height: 12pt; padding-right: 0px; width: 100%; background-color: #f4f4f4"><span id="lnum14" style="color: #606060"> 14:</span> }</pre>
<!--CRLF-->
<pre style="border-top-style: none; overflow: visible; font-size: 8pt; border-left-style: none; font-family: 'Courier New', courier, monospace; border-bottom-style: none; color: black; padding-bottom: 0px; direction: ltr; text-align: left; padding-top: 0px; border-right-style: none; padding-left: 0px; margin: 0em; line-height: 12pt; padding-right: 0px; width: 100%; background-color: white"><span id="lnum15" style="color: #606060"> 15:</span> }</pre>
<!--CRLF--></div>
</div>
<p> </p>
<p>When this is done we can now access our propertys on the TranslationPage with:</p>
<div id="codeSnippetWrapper" style="overflow: auto; cursor: text; font-size: 8pt; border-top: silver 1px solid; font-family: 'Courier New', courier, monospace; border-right: silver 1px solid; border-bottom: silver 1px solid; padding-bottom: 4px; direction: ltr; text-align: left; padding-top: 4px; padding-left: 4px; margin: 20px 0px 10px; border-left: silver 1px solid; line-height: 12pt; padding-right: 4px; max-height: 200px; width: 97.5%; background-color: #f4f4f4">
<div id="codeSnippet" style="border-top-style: none; overflow: visible; font-size: 8pt; border-left-style: none; font-family: 'Courier New', courier, monospace; border-bottom-style: none; color: black; padding-bottom: 0px; direction: ltr; text-align: left; padding-top: 0px; border-right-style: none; padding-left: 0px; line-height: 12pt; padding-right: 0px; width: 100%; background-color: #f4f4f4">
<pre style="border-top-style: none; overflow: visible; font-size: 8pt; border-left-style: none; font-family: 'Courier New', courier, monospace; border-bottom-style: none; color: black; padding-bottom: 0px; direction: ltr; text-align: left; padding-top: 0px; border-right-style: none; padding-left: 0px; margin: 0em; line-height: 12pt; padding-right: 0px; width: 100%; background-color: white"><span id="lnum1" style="color: #606060"> 1:</span> TranslationPage.MyLabel;</pre>
<!--CRLF--></div>
</div>
<p> </p>
<p>If we are kind to our editors we can also use a fallback, either with some external resource like xml or just add a value if empty:</p>
<div id="codeSnippetWrapper" style="overflow: auto; cursor: text; font-size: 8pt; border-top: silver 1px solid; font-family: 'Courier New', courier, monospace; border-right: silver 1px solid; border-bottom: silver 1px solid; padding-bottom: 4px; direction: ltr; text-align: left; padding-top: 4px; padding-left: 4px; margin: 20px 0px 10px; border-left: silver 1px solid; line-height: 12pt; padding-right: 4px; max-height: 200px; width: 97.5%; background-color: #f4f4f4">
<div id="codeSnippet" style="border-top-style: none; overflow: visible; font-size: 8pt; border-left-style: none; font-family: 'Courier New', courier, monospace; border-bottom-style: none; color: black; padding-bottom: 0px; direction: ltr; text-align: left; padding-top: 0px; border-right-style: none; padding-left: 0px; line-height: 12pt; padding-right: 0px; width: 100%; background-color: #f4f4f4">
<pre style="border-top-style: none; overflow: visible; font-size: 8pt; border-left-style: none; font-family: 'Courier New', courier, monospace; border-bottom-style: none; color: black; padding-bottom: 0px; direction: ltr; text-align: left; padding-top: 0px; border-right-style: none; padding-left: 0px; margin: 0em; line-height: 12pt; padding-right: 0px; width: 100%; background-color: white"><span id="lnum1" style="color: #606060"> 1:</span> TranslationPage.MyLabel ?? <span style="color: #006080">"Text that you can translat in episerver"</span>;</pre>
<!--CRLF--></div>
</div>
<p> </p>
<p>Finally we have to create a new page inside EPiServer based on TranslatePage and set the property on StartPage to the new page for translation. When that is done we can use the page for labels and other information that needs to be translated but is not a part of a ordinary page, for instance labels for search.</p>
Example of baseclass and access to StartPage in your CMS 7 projects
/blogs/Eric-Pettersson/Dates/2013/2/Example-of-baseclass-and-access-to-StartPage-in-your-CMS-7-projects/
2013-02-01T16:09:15.0000000Z
<p>When you start developing your EPiServer CMS 7 website you will get the new features for building pagetypes directly in code. An important message at the developer course is to create your own base class for the templates and user controls that you develop in your project. When you start developing you will probably have to reference your StartPage from time to time, we often have global settings and other important properties on the startpage. For instance you might have properties on the startpage where you change information in the site footer or links to external sites. This is a great way of using the startpage since we have access to that page via the API in EPiServer:</p> <div style="border-bottom: silver 1px solid; text-align: left; border-left: silver 1px solid; padding-bottom: 4px; line-height: 12pt; background-color: #f4f4f4; margin: 20px 0px 10px; padding-left: 4px; width: 97.5%; padding-right: 4px; font-family: 'Courier New', courier, monospace; direction: ltr; max-height: 200px; font-size: 8pt; overflow: auto; border-top: silver 1px solid; cursor: text; border-right: silver 1px solid; padding-top: 4px" id="codeSnippetWrapper"> <div style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: #f4f4f4; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px" id="codeSnippet"> <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: white; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum1"> 1:</span> PageReference.StartPage;</pre>
<!--CRLF-->
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: #f4f4f4; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum2"> 2:</span> </pre>
<!--CRLF-->
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: white; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum3"> 3:</span> ContentReference.StartPage;</pre>
<!--CRLF--></div>
</div>
<p> </p>
<p>When we get our properties from the startpage we can now use the ServiceLocater helper class in CMS 7 and ContentRepository() combined with the new and shiny Get<T>:</p>
<div style="border-bottom: silver 1px solid; text-align: left; border-left: silver 1px solid; padding-bottom: 4px; line-height: 12pt; background-color: #f4f4f4; margin: 20px 0px 10px; padding-left: 4px; width: 97.5%; padding-right: 4px; font-family: 'Courier New', courier, monospace; direction: ltr; max-height: 200px; font-size: 8pt; overflow: auto; border-top: silver 1px solid; cursor: text; border-right: silver 1px solid; padding-top: 4px" id="codeSnippetWrapper">
<div style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: #f4f4f4; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px" id="codeSnippet">
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: white; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum1"> 1:</span> var prop = </pre>
<!--CRLF-->
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: #f4f4f4; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum2"> 2:</span> Locate.ContentRepository().Get<StartPageType>(ContentReference.StartPage).YourProperty;</pre>
<!--CRLF--></div>
</div>
<p>Doing this all the time is not that funny when binding lists and other functions in for instance the site footer. So instead of doing this all the time we create a base class for both usercontrols and templates. In this base class we add our StartPage-object:</p>
<div style="border-bottom: silver 1px solid; text-align: left; border-left: silver 1px solid; padding-bottom: 4px; line-height: 12pt; background-color: #f4f4f4; margin: 20px 0px 10px; padding-left: 4px; width: 97.5%; padding-right: 4px; font-family: 'Courier New', courier, monospace; direction: ltr; max-height: 200px; font-size: 8pt; overflow: auto; border-top: silver 1px solid; cursor: text; border-right: silver 1px solid; padding-top: 4px" id="codeSnippetWrapper">
<div style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: #f4f4f4; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px" id="codeSnippet">
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: white; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum1"> 1:</span> <span style="color: #0000ff">public</span> <span style="color: #0000ff">class</span> SiteUserControlBase : EPiServer.UserControlBase</pre>
<!--CRLF-->
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: #f4f4f4; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum2"> 2:</span> {</pre>
<!--CRLF-->
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: white; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum3"> 3:</span> <span style="color: #0000ff">private</span> StartPageType mStartPage;</pre>
<!--CRLF-->
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: #f4f4f4; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum4"> 4:</span>  </pre>
<!--CRLF-->
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: white; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum5"> 5:</span> <span style="color: #008000">/// <summary></span></pre>
<!--CRLF-->
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: #f4f4f4; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum6"> 6:</span> <span style="color: #008000">/// Start page for the web site</span></pre>
<!--CRLF-->
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: white; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum7"> 7:</span> <span style="color: #008000">/// </summary></span></pre>
<!--CRLF-->
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: #f4f4f4; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum8"> 8:</span> <span style="color: #0000ff">public</span> StartPageType StartPage</pre>
<!--CRLF-->
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: white; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum9"> 9:</span> {</pre>
<!--CRLF-->
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: #f4f4f4; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum10"> 10:</span> get</pre>
<!--CRLF-->
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: white; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum11"> 11:</span> {</pre>
<!--CRLF-->
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: #f4f4f4; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum12"> 12:</span> <span style="color: #0000ff">if</span> (mStartPage == <span style="color: #0000ff">null</span>)</pre>
<!--CRLF-->
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: white; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum13"> 13:</span> {</pre>
<!--CRLF-->
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: #f4f4f4; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum14"> 14:</span> mStartPage = Locate.ContentRepository().Get<StartPageType>(ContentReference.StartPage);</pre>
<!--CRLF-->
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: white; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum15"> 15:</span> }</pre>
<!--CRLF-->
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: #f4f4f4; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum16"> 16:</span>  </pre>
<!--CRLF-->
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: white; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum17"> 17:</span> <span style="color: #0000ff">return</span> mStartPage;</pre>
<!--CRLF-->
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: #f4f4f4; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum18"> 18:</span> }</pre>
<!--CRLF-->
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: white; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum19"> 19:</span> }</pre>
<!--CRLF-->
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: #f4f4f4; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum20"> 20:</span> }</pre>
<!--CRLF--></div>
</div>
<p>Now you make sure you inherit the new class in your usercontrols. By doing this you can now start to use the StartPage as strongly typed directly when accessing propertys in your code: </p>
<div style="border-bottom: silver 1px solid; text-align: left; border-left: silver 1px solid; padding-bottom: 4px; line-height: 12pt; background-color: #f4f4f4; margin: 20px 0px 10px; padding-left: 4px; width: 97.5%; padding-right: 4px; font-family: 'Courier New', courier, monospace; direction: ltr; max-height: 200px; font-size: 8pt; overflow: auto; border-top: silver 1px solid; cursor: text; border-right: silver 1px solid; padding-top: 4px" id="codeSnippetWrapper">
<div style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: #f4f4f4; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px" id="codeSnippet">
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: white; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum1"> 1:</span> <span style="color: #0000ff"><</span><span style="color: #800000">asp:Literal</span> <span style="color: #ff0000">runat</span><span style="color: #0000ff">="server"</span> <span style="color: #ff0000">ID</span><span style="color: #0000ff">="test"</span><span style="color: #0000ff">></</span><span style="color: #800000">asp:Literal</span><span style="color: #0000ff">></span></pre>
<!--CRLF-->
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: #f4f4f4; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum2"> 2:</span>  </pre>
<!--CRLF-->
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: white; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum3"> 3:</span> <span style="color: #0000ff"><</span><span style="color: #800000">EPiServer:Property</span> <span style="color: #ff0000">runat</span><span style="color: #0000ff">="server"</span> <span style="color: #ff0000">ID</span><span style="color: #0000ff">="EPiPropertyCtrl"</span><span style="color: #0000ff">></</span><span style="color: #800000">EPiServer:Property</span><span style="color: #0000ff">></span></pre>
<!--CRLF--></div>
</div>
<div style="border-bottom: silver 1px solid; text-align: left; border-left: silver 1px solid; padding-bottom: 4px; line-height: 12pt; background-color: #f4f4f4; margin: 20px 0px 10px; padding-left: 4px; width: 97.5%; padding-right: 4px; font-family: 'Courier New', courier, monospace; direction: ltr; max-height: 200px; font-size: 8pt; overflow: auto; border-top: silver 1px solid; cursor: text; border-right: silver 1px solid; padding-top: 4px" id="codeSnippetWrapper">
<div style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: #f4f4f4; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px" id="codeSnippet">
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: white; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum1"> 1:</span> test.Text = StartPage.SearchLegend;</pre>
<!--CRLF-->
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: #f4f4f4; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum2"> 2:</span>  </pre>
<!--CRLF-->
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: white; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum3"> 3:</span> EPiPropertyCtrl.PageLink = StartPage.PageLink;</pre>
<!--CRLF-->
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: #f4f4f4; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum4"> 4:</span>  </pre>
<!--CRLF-->
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: white; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum5"> 5:</span> EPiPropertyCtrl.PropertyName = StartPage.GetPropertyName(p => p.SearchLegend);</pre>
<!--CRLF--></div>
</div>
<p>Using the webcontrol will ensure you have the correct attributes when it comes to editing on page in CMS 7.</p>
<p>Might not be the best example but hey it works <img style="border-bottom-style: none; border-left-style: none; border-top-style: none; border-right-style: none" class="wlEmoticon wlEmoticon-smile" alt="Ler" src="/link/8561d01fe2f64875b83dea30ebc707a0.png" /></p>
<p>Have a nice weekend, I will!!</p>
Failed to register URL for your website when using VS2012 and IIS Express?
/blogs/Eric-Pettersson/Dates/2012/12/Failed-to-register-URL-for-your-website-when-using-VS2012-and-IIS-Express/
2012-12-29T12:10:06.0000000Z
<p>I am setting up a new project with CMS 7 and stumble upon a problem with running EPiServer CMS7 with IIS Express. Thought I should write a quick answer to the problem.</p> <p>If you are getting this error:</p> <p><a href="/link/978bfe1519174d268313339e6272cfff.png"><img style="background-image: none; border-bottom: 0px; border-left: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top: 0px; border-right: 0px; padding-top: 0px" title="image" border="0" alt="image" src="/link/6d452e98124748ba9a27132ea0a2edc9.png" width="504" height="223" /></a></p> <p> </p> <p>To fix this issue you just need to run your instance of VS2012 as an administrator.</p> <p> </p> <p><a href="/link/b63c52b002a043ccbdf5cdad994e3b76.png"><img style="background-image: none; border-bottom: 0px; border-left: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top: 0px; border-right: 0px; padding-top: 0px" title="image" border="0" alt="image" src="/link/9ae68423a457447a935a83ccbc998901.png" width="512" height="339" /></a></p> <p> </p> <p>When that is done you can run your application with IIS Express.</p>
Container pages for EPiServer CMS 6 based on PageTypeBuilder
/blogs/Eric-Pettersson/Dates/2012/12/Container-pages-for-EPiServer-CMS-6-based-on-PageTypeBuilder/
2012-12-14T14:53:33.0000000Z
<p>Remember the new feature called Container-pages that came with CMS 6 R2 edition? If you don’t remember it is ok cause most of the project never use them since PageTypeBuilder did not support that. I say did cause I am not that updated on PageTypeBuilder at the moment. <img style="border-bottom-style: none; border-left-style: none; border-top-style: none; border-right-style: none" class="wlEmoticon wlEmoticon-smile" alt="Ler" src="/link/b57eac2ad34c4569a80bcf5ff8f44122.png" /> </p> <p>But I think they are a nice feature that I also promote at developer courses. When I build new websites and structure the content I tend to use them and in the early days of EPiServer we used ordinary pagtypes for this.  If you do not know what they are I suggest you read the blog post that Linus wrote when this feature were released, <a title="http://world.episerver.com/Blogs/Linus-Ekstrom/Dates/2011/3/Container-pages/" href="http://world.episerver.com/Blogs/Linus-Ekstrom/Dates/2011/3/Container-pages/">http://world.episerver.com/Blogs/Linus-Ekstrom/Dates/2011/3/Container-pages/</a></p> <p>So, a quick answer is: A PageType without a template! <img style="border-bottom-style: none; border-left-style: none; border-top-style: none; border-right-style: none" class="wlEmoticon wlEmoticon-smile" alt="Ler" src="/link/b57eac2ad34c4569a80bcf5ff8f44122.png" /></p> <p>They will have a special rendering inside edit-mode looking like the image below and also other nice features that Linus mentioned in his blog post. </p> <p><a href="/link/7335f83261d74e4a904c95d892e2205e.jpg"><img style="background-image: none; border-bottom: 0px; border-left: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top: 0px; border-right: 0px; padding-top: 0px" title="clip_image002" border="0" alt="clip_image002" src="/link/57ee7bd4775843d6b2e45aeb910ca9ec.jpg" width="462" height="206" /></a></p> <h2>Render Container-pages with PageTypeBuilder</h2> <p>The problem with PageTypeBuilder is that by default if you leave the “Filename” empty it will fallback to default.aspx or something like that. So we need to force the website to render specific PageTypes like container pages. This can be done in Global.asax.</p> <h3>Add EventHandlers to Global.asax</h3> <p>We need to add two new eventhandlers to global.asax, these will be added to Application_Start.</p> <div style="border-bottom: silver 1px solid; text-align: left; border-left: silver 1px solid; padding-bottom: 4px; line-height: 12pt; background-color: #f4f4f4; margin: 20px 0px 10px; padding-left: 4px; width: 97.5%; padding-right: 4px; font-family: 'Courier New', courier, monospace; direction: ltr; max-height: 200px; font-size: 8pt; overflow: auto; border-top: silver 1px solid; cursor: text; border-right: silver 1px solid; padding-top: 4px" id="codeSnippetWrapper"> <div style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: #f4f4f4; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px" id="codeSnippet"> <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: white; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"><span style="color: #0000ff">protected</span> <span style="color: #0000ff">void</span> Application_Start(Object sender, EventArgs e)</pre>
<!--CRLF-->
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: #f4f4f4; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px">{</pre>
<!--CRLF-->
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: white; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"> EditPanel.LoadedPage += <span style="color: #0000ff">new</span> LoadedPageEventHandler(EditPanel_LoadedPage);</pre>
<!--CRLF-->
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: #f4f4f4; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"> DataFactory.Instance.LoadedPage += <span style="color: #0000ff">new</span> PageEventHandler(Instance_LoadedPage);</pre>
<!--CRLF-->
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: white; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px">}</pre>
<!--CRLF--></div>
</div>
<p>Next we create a class for handling all the PageTypes that should be rendered as ContainerPages. </p>
<h3>ContainerPages.cs</h3>
<p>Here we use PageTypeResolver from PageTypeBuilder to get our Id:s for our different pagetypes.</p>
<div style="border-bottom: silver 1px solid; text-align: left; border-left: silver 1px solid; padding-bottom: 4px; line-height: 12pt; background-color: #f4f4f4; margin: 20px 0px 10px; padding-left: 4px; width: 97.5%; padding-right: 4px; font-family: 'Courier New', courier, monospace; direction: ltr; max-height: 200px; font-size: 8pt; overflow: auto; border-top: silver 1px solid; cursor: text; border-right: silver 1px solid; padding-top: 4px" id="codeSnippetWrapper">
<div style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: #f4f4f4; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px" id="codeSnippet">
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: white; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"><span style="color: #0000ff">public</span> <span style="color: #0000ff">class</span> ContainerPages</pre>
<!--CRLF-->
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: #f4f4f4; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px">{</pre>
<!--CRLF-->
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: white; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"> <span style="color: #008000">//Pagetypes without view mode</span></pre>
<!--CRLF-->
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: #f4f4f4; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"> <span style="color: #0000ff">public</span> <span style="color: #0000ff">static</span> <span style="color: #0000ff">readonly</span> <span style="color: #0000ff">int</span>?[] ContainerPageIds = <span style="color: #0000ff">new</span>[]</pre>
<!--CRLF-->
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: white; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"> {</pre>
<!--CRLF-->
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: #f4f4f4; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"> </pre>
<!--CRLF-->
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: white; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"> PageTypeResolver.Instance.GetPageTypeID(<span style="color: #0000ff">typeof</span> (MyPageType)),</pre>
<!--CRLF-->
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: #f4f4f4; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"> PageTypeResolver.Instance.GetPageTypeID(<span style="color: #0000ff">typeof</span> (OtherPageType))</pre>
<!--CRLF-->
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: white; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"> </pre>
<!--CRLF-->
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: #f4f4f4; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"> };</pre>
<!--CRLF-->
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: white; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px">}</pre>
<!--CRLF--></div>
</div>
<p>Next we add some logic to the newly created eventhandlers, so we open global.asax again.</p>
<h3>Our code in global.asax</h3>
<div style="border-bottom: silver 1px solid; text-align: left; border-left: silver 1px solid; padding-bottom: 4px; line-height: 12pt; background-color: #f4f4f4; margin: 20px 0px 10px; padding-left: 4px; width: 97.5%; padding-right: 4px; font-family: 'Courier New', courier, monospace; direction: ltr; max-height: 200px; font-size: 8pt; overflow: auto; border-top: silver 1px solid; cursor: text; border-right: silver 1px solid; padding-top: 4px" id="codeSnippetWrapper">
<div style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: #f4f4f4; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px" id="codeSnippet">
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: white; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"><span style="color: #0000ff">public</span> <span style="color: #0000ff">void</span> EditPanel_LoadedPage(EditPanel sender, LoadedPageEventArgs e)</pre>
<!--CRLF-->
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: #f4f4f4; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px">{</pre>
<!--CRLF-->
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: white; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"> </pre>
<!--CRLF-->
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: #f4f4f4; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"> <span style="color: #0000ff">if</span> (e.Page != <span style="color: #0000ff">null</span> && ContainerPages.ContainerPageIds.Any(containerPageId => e.Page.PageTypeID == containerPageId))</pre>
<!--CRLF-->
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: white; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"> {</pre>
<!--CRLF-->
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: #f4f4f4; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"> e.Page.HasTemplate = <span style="color: #0000ff">false</span>;</pre>
<!--CRLF-->
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: white; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"> }</pre>
<!--CRLF-->
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: #f4f4f4; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px">}</pre>
<!--CRLF-->
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: white; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"> </pre>
<!--CRLF-->
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: #f4f4f4; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"><span style="color: #0000ff">public</span> <span style="color: #0000ff">void</span> Instance_LoadedPage(<span style="color: #0000ff">object</span> sender, PageEventArgs e)</pre>
<!--CRLF-->
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: white; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px">{</pre>
<!--CRLF-->
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: #f4f4f4; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"> <span style="color: #0000ff">if</span> (e.Page != <span style="color: #0000ff">null</span> && ContainerPages.ContainerPageIds != <span style="color: #0000ff">null</span> && ContainerPages.ContainerPageIds.Any(containerPageId => e.Page.PageTypeID == containerPageId))</pre>
<!--CRLF-->
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: white; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"> {</pre>
<!--CRLF-->
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: #f4f4f4; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"> e.Page.HasTemplate = <span style="color: #0000ff">false</span>;</pre>
<!--CRLF-->
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: white; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"> }</pre>
<!--CRLF-->
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: #f4f4f4; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px">}</pre>
<!--CRLF--></div>
</div>
<p>Finally we need to add some code to our PageTypes, telling them that the do not have any Template:</p>
<div style="border-bottom: silver 1px solid; text-align: left; border-left: silver 1px solid; padding-bottom: 4px; line-height: 12pt; background-color: #f4f4f4; margin: 20px 0px 10px; padding-left: 4px; width: 97.5%; padding-right: 4px; font-family: 'Courier New', courier, monospace; direction: ltr; max-height: 200px; font-size: 8pt; overflow: auto; border-top: silver 1px solid; cursor: text; border-right: silver 1px solid; padding-top: 4px" id="codeSnippetWrapper">
<div style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: #f4f4f4; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px" id="codeSnippet">
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: white; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px">[PageType(Name = <span style="color: #006080">"MyPageType"</span>, FileName=<span style="color: #006080">""</span>)]</pre>
<!--CRLF-->
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: #f4f4f4; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"><span style="color: #0000ff">public</span> <span style="color: #0000ff">class</span> MyPageType : TypedPagedData</pre>
<!--CRLF-->
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: white; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px">{</pre>
<!--CRLF-->
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: #f4f4f4; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"> <span style="color: #0000ff">public</span> MyPageType()</pre>
<!--CRLF-->
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: white; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"> {</pre>
<!--CRLF-->
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: #f4f4f4; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"> HasTemplate = <span style="color: #0000ff">false</span>;</pre>
<!--CRLF-->
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: white; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"> }</pre>
<!--CRLF-->
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: #f4f4f4; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px">}</pre>
<!--CRLF--></div>
</div>
<p>That is about it.</p>
<p>Not sure this is the best way or if I am doing anything wrong but it looks like it is working ok. It also might work with only the last piece of code, so please give feedback! <img style="border-bottom-style: none; border-left-style: none; border-top-style: none; border-right-style: none" class="wlEmoticon wlEmoticon-smile" alt="Ler" src="/link/b57eac2ad34c4569a80bcf5ff8f44122.png" /></p>
Missing Context Menu for EPiServer Community
/blogs/Eric-Pettersson/Dates/2012/12/Missing-Context-Menu-for-EPiServer-Community/
2012-12-05T14:35:26.0000000Z
<p>I have stumbled upon installations of EPiServer Community that are missing the “Context Menu”-option for Admin and Moderation. I have always thought that someone had done a mistake or that the upgrade process from EPiServer where missing to add some parts to web.config. </p> <p>But today I found the solution and since I could not find any blog about the issue I thought I should share it with you. </p> <p>The problem occurs when you upgrade an existing EPiServer Community installation to the latest. If you install a brand new Relate website with deployment center this will not happen. So why is these options missing.</p> <p>Well what they forgot to tell us is that in the latest Relate package for CMS 6 they have added a PagePlugin!! <img style="border-bottom-style: none; border-left-style: none; border-top-style: none; border-right-style: none" class="wlEmoticon wlEmoticon-smile" alt="Ler" src="/link/8c49e61f9a7a4372b814706c85efc1a4.png" /> So no missing configs or other stuff… they just did not ad that to the product but to the sample project, what if we needed to ad the Context Menu to every CMS project.. would be fun right!? <img style="border-bottom-style: none; border-left-style: none; border-top-style: none; border-right-style: none" class="wlEmoticon wlEmoticon-winkingsmile" alt="Blinkar" src="/link/ba5e1336778748e59ac9ab0981dc71a1.png" /></p> <p>Well the code for the plugin is the following:</p> <div style="border-bottom: silver 1px solid; text-align: left; border-left: silver 1px solid; padding-bottom: 4px; line-height: 12pt; background-color: #f4f4f4; margin: 20px 0px 10px; padding-left: 4px; width: 97.5%; padding-right: 4px; font-family: 'Courier New', courier, monospace; direction: ltr; max-height: 200px; font-size: 8pt; overflow: auto; border-top: silver 1px solid; cursor: text; border-right: silver 1px solid; padding-top: 4px" id="codeSnippetWrapper"> <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: #f4f4f4; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px" id="codeSnippet"><span style="color: #008000">/// <summary></span><br /> <span style="color: #008000">/// Plugin to add Community item to page context menu</span><br /> <span style="color: #008000">/// </summary></span><br /> [PagePlugIn(Description = <span style="color: #006080">"Adds Community item to page context menu."</span>, DisplayName = <span style="color: #006080">"Community context menu"</span>,<br /> RequireLicenseForLoad = <span style="color: #0000ff">false</span>, SortIndex = 2000)]<br /> <span style="color: #0000ff">public</span> <span style="color: #0000ff">class</span> ContextMenuPlugIn<br /> {<br /> <span style="color: #008000">/// <summary></span><br /> <span style="color: #008000">/// Community item name in context menu</span><br /> <span style="color: #008000">/// </summary></span><br /> <span style="color: #0000ff">private</span> <span style="color: #0000ff">const</span> <span style="color: #0000ff">string</span> _menuItemNameAdmin = <span style="color: #006080">"CommunityMenuItemAdmin"</span>;<br /> <span style="color: #0000ff">private</span> <span style="color: #0000ff">const</span> <span style="color: #0000ff">string</span> _menuItemNameModerate = <span style="color: #006080">"CommunityMenuItemModerate"</span>;<br /> <br /> <span style="color: #008000">/// <summary></span><br /> <span style="color: #008000">/// Page paths</span><br /> <span style="color: #008000">/// </summary></span><br /> <span style="color: #0000ff">private</span> <span style="color: #0000ff">static</span> <span style="color: #0000ff">readonly</span> <span style="color: #0000ff">string</span> _moderatePagePath = VirtualPathUtilityEx.ToAbsolute(<span style="color: #006080">"~/EPiServerCommunity/Moderate.aspx"</span>);<br /> <span style="color: #0000ff">private</span> <span style="color: #0000ff">static</span> <span style="color: #0000ff">readonly</span> <span style="color: #0000ff">string</span> _adminPagePath = VirtualPathUtilityEx.ToAbsolute(<span style="color: #006080">"~/EPiServerCommunity/Admin.aspx"</span>);<br /> <br /> <span style="color: #008000">/// <summary></span><br /> <span style="color: #008000">/// Initializes pluging.</span><br /> <span style="color: #008000">/// </summary></span><br /> <span style="color: #008000">/// <param name = "optionFlag">The option flag.</param></span><br /> <span style="color: #0000ff">public</span> <span style="color: #0000ff">static</span> <span style="color: #0000ff">void</span> Initialize(<span style="color: #0000ff">int</span> optionFlag)<br /> {<br /> PageBase.PageSetup += PageSetupHandler;<br /> }<br /> <br /> <span style="color: #008000">/// <summary></span><br /> <span style="color: #008000">/// Gets a value indicating whether this plugin is enabled.</span><br /> <span style="color: #008000">/// </summary></span><br /> <span style="color: #008000">/// <value><c>true</c> if enabled; otherwise, <c>false</c>.</value></span><br /> <span style="color: #0000ff">private</span> <span style="color: #0000ff">static</span> <span style="color: #0000ff">bool</span> Enabled<br /> {<br /> get<br /> {<br /> PlugInDescriptor descriptor = PlugInDescriptor.Load(<span style="color: #0000ff">typeof</span>(ContextMenuPlugIn));<br /> <span style="color: #0000ff">return</span> descriptor != <span style="color: #0000ff">null</span> && descriptor.Enabled;<br /> }<br /> }<br /> <br /> <span style="color: #008000">/// <summary></span><br /> <span style="color: #008000">/// Handle page Setup event.</span><br /> <span style="color: #008000">/// </summary></span><br /> <span style="color: #008000">/// <param name = "page">The page.</param></span><br /> <span style="color: #008000">/// <param name = "e">The <see cref = "EPiServer.PageSetupEventArgs" /> instance containing the event data.</param></span><br /> <span style="color: #0000ff">public</span> <span style="color: #0000ff">static</span> <span style="color: #0000ff">void</span> PageSetupHandler(PageBase page, PageSetupEventArgs e)<br /> {<br /> <span style="color: #0000ff">if</span> (!Enabled)<br /> {<br /> <span style="color: #0000ff">return</span>;<br /> }<br /> <br /> page.Init += PageInitHandler;<br /> }<br /> <br /> <span style="color: #008000">/// <summary></span><br /> <span style="color: #008000">/// Handle page Init event and adds Community menu item.</span><br /> <span style="color: #008000">/// </summary></span><br /> <span style="color: #008000">/// <param name = "sender">The sender.</param></span><br /> <span style="color: #008000">/// <param name = "e">The <see cref = "System.EventArgs" /> instance containing the event data.</param></span><br /> <span style="color: #0000ff">static</span> <span style="color: #0000ff">void</span> PageInitHandler(<span style="color: #0000ff">object</span> sender, EventArgs e)<br /> {<br /> var page = sender <span style="color: #0000ff">as</span> PageBase;<br /> <span style="color: #0000ff">if</span> (page == <span style="color: #0000ff">null</span> || page.ContextMenu == <span style="color: #0000ff">null</span> || !page.ContextMenu.IsMenuEnabled || page.ContextMenu.Menu.Items == <span style="color: #0000ff">null</span>)<br /> {<br /> <span style="color: #0000ff">return</span>;<br /> }<br /> IUser currentUser = CommunitySystem.CurrentContext.DefaultSecurity.CurrentUser;<br /> <span style="color: #0000ff">if</span> (!page.ContextMenu.Menu.Items.Contains(_menuItemNameModerate) && CanAccessModeratorMode(currentUser))<br /> {<br /> var menuItem = <span style="color: #0000ff">new</span> RightClickMenuItem(<br /> <span style="color: #006080">"olle"</span>,<br /> _moderatePagePath,<br /> <span style="color: #0000ff">null</span>,<br /> <span style="color: #006080">"true"</span>,<br /> VirtualPathUtilityEx.ToAbsolute(<span style="color: #006080">"~/Templates/RelatePlus/Styles/Images/icons/CommunityModeration.png"</span>), <br /> RightClickMode.All);<br /> page.ContextMenu.Menu.Add(_menuItemNameModerate, menuItem);<br /> }<br /> <br /> <span style="color: #0000ff">if</span> (!page.ContextMenu.Menu.Items.Contains(_menuItemNameAdmin) && currentUser.IsCommunityAdmin())<br /> {<br /> var menuItem = <span style="color: #0000ff">new</span> RightClickMenuItem(<br /> LanguageManager.Instance.Translate(<span style="color: #006080">"/contextmenuplugin/adminmode"</span>),<br /> _adminPagePath,<br /> <span style="color: #0000ff">null</span>,<br /> <span style="color: #006080">"true"</span>,<br /> VirtualPathUtilityEx.ToAbsolute(<span style="color: #006080">"~/Templates/RelatePlus/Styles/Images/icons/CommunityAdmin.png"</span>),<br /> RightClickMode.All);<br /> <br /> page.ContextMenu.Menu.Add(_menuItemNameAdmin, menuItem);<br /> }<br /> }<br /> <br /> <span style="color: #0000ff">private</span> <span style="color: #0000ff">static</span> <span style="color: #0000ff">bool</span> CanAccessModeratorMode(IUser currentUser)<br /> {<br /> <span style="color: #0000ff">return</span> currentUser.IsCommunityModerator() || currentUser.IsCommunityAdmin();<br /> }<br /> }<br /></pre>
<br /></div>
<p> </p>
<p>Have a look in the Relate website and you will find the plugin as well as the images and translationfiles.</p>
Styling ordered lists in the xhtml-editor using only CSS
/blogs/Eric-Pettersson/Dates/2012/4/Styling-ordered-lists-in-the-xhtml-editor-using-only-CSS/
2012-04-03T12:28:27.0000000Z
<p>This is a really nice approach of styling lists and you should use it <img style="border-bottom-style: none; border-left-style: none; border-top-style: none; border-right-style: none" class="wlEmoticon wlEmoticon-smile" alt="Ler" src="/link/819f34e84bfe4a7c8696a0b3b90c178d.png" /></p> <p>In most of our project we tend to forget to style the ordinary content, the content that should be most important to style. A couple of weeks ago i read this blogpost by Maria Sogneforst, <a title="http://7minds.se/blogg/2012/2/texter-som-man-sa-ofta-glommer-att-ge-design/" href="http://7minds.se/blogg/2012/2/texter-som-man-sa-ofta-glommer-att-ge-design/">http://7minds.se/blogg/2012/2/texter-som-man-sa-ofta-glommer-att-ge-design/</a> (Swedish), where she discuss the topic of styling the content that the editors produce.</p> <p>So this blogpost is about how you can use CSS to style your list. Now you probably think you know that already but how would you style a list looking like this:</p> <p><a href="/link/b6ad18f3bcac4b95b2ec37d3e6b1c80e.png"><img style="background-image: none; border-right-width: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px; padding-top: 0px" title="image" border="0" alt="image" src="/link/7c67d8fb912045ce813996321aa4108b.png" width="238" height="152" /></a></p> <p>The problem is that I have a list with numbers larger, other color and other font, then the rest of the list.</p> <p>One approach of solving this problem is that you can prevent the browser from rendering the numbers using: list-style: none. Then you add the numbers with code in the ordinary content of your list using a span-tag or something like that. This will work if you have complete access to the code rendering the list.</p> <p><strong>But that is not a solution that we can use, when we have no control of the list, and that is the case when we are working with content from the editor.</strong></p> <p>Also if you are working with lists like the above example it will work visually but it is not semanticlly correct, and we do not like that do we!?</p> <p>To solve this we need to work with something called <a href="http://www.w3.org/TR/CSS21/generate.html">CSS Generated Content</a>. When using this technique we create and insert the counter-number after removing the defualt numbers or dots.</p> <p>We will use something that is called the content-property and the before and after psuedo-elements. A quick example.</p> <p>Insert text before all your P-elements using this:</p> <div style="border-bottom: silver 1px solid; text-align: left; border-left: silver 1px solid; padding-bottom: 4px; line-height: 12pt; background-color: #f4f4f4; margin: 20px 0px 10px; padding-left: 4px; width: 97.5%; padding-right: 4px; font-family: 'Courier New', courier, monospace; direction: ltr; max-height: 200px; font-size: 8pt; overflow: auto; border-top: silver 1px solid; cursor: text; border-right: silver 1px solid; padding-top: 4px" id="codeSnippetWrapper"> <div style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: #f4f4f4; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px" id="codeSnippet"> <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: white; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"><span style="color: #0000ff">p</span>:before {<span style="color: #0000ff">content</span>: <span style="color: #006080">"Hello World";</span>}</pre>
<!--CRLF--></div>
</div>
<p> </p>
<p>So how did i style the list above? Well this is the code that I used:</p>
<p>The things that you should focus on is that I have disabled the default numbering and also use the counter-reset property and the counter-increment property, <a href="http://www.w3.org/TR/CSS21/generate.html#counters">http://www.w3.org/TR/CSS21/generate.html#counters</a></p>
<div style="border-bottom: silver 1px solid; text-align: left; border-left: silver 1px solid; padding-bottom: 4px; line-height: 12pt; background-color: #f4f4f4; margin: 20px 0px 10px; padding-left: 4px; width: 97.5%; padding-right: 4px; font-family: 'Courier New', courier, monospace; direction: ltr; max-height: 200px; font-size: 8pt; overflow: auto; border-top: silver 1px solid; cursor: text; border-right: silver 1px solid; padding-top: 4px" id="codeSnippetWrapper">
<div style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: #f4f4f4; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px" id="codeSnippet">
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: white; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"><span style="color: #0000ff">div</span>#mainbody <span style="color: #0000ff">ol</span></pre>
<!--CRLF-->
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: #f4f4f4; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px">{</pre>
<!--CRLF-->
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: white; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"> <span style="color: #0000ff">counter-reset</span>: <span style="color: #006080">li;</span></pre>
<!--CRLF-->
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: #f4f4f4; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"> <span style="color: #0000ff">margin</span>-<span style="color: #0000ff">left</span>: <span style="color: #006080">10px;</span></pre>
<!--CRLF-->
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: white; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"> <span style="color: #0000ff">padding</span>-<span style="color: #0000ff">left</span>: 0;</pre>
<!--CRLF-->
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: #f4f4f4; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px">}</pre>
<!--CRLF-->
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: white; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"><span style="color: #0000ff">div</span>#mainbody <span style="color: #0000ff">ol</span> <span style="color: #006080">></span> <span style="color: #0000ff">li</span></pre>
<!--CRLF-->
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: #f4f4f4; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px">{</pre>
<!--CRLF-->
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: white; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"> <span style="color: #0000ff">position</span>: <span style="color: #006080">relative;</span></pre>
<!--CRLF-->
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: #f4f4f4; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"> <span style="color: #0000ff">margin</span>: <span style="color: #006080">0 0 6px 2em;</span></pre>
<!--CRLF-->
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: white; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"> <span style="color: #0000ff">padding</span>: <span style="color: #006080">4px 8px;</span></pre>
<!--CRLF-->
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: #f4f4f4; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"> <span style="color: #0000ff">list-style</span>: <span style="color: #006080">none;</span></pre>
<!--CRLF-->
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: white; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px">}</pre>
<!--CRLF-->
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: #f4f4f4; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"><span style="color: #0000ff">div</span>#mainbody <span style="color: #0000ff">ol</span> <span style="color: #006080">></span> <span style="color: #0000ff">li</span>:before</pre>
<!--CRLF-->
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: white; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px">{</pre>
<!--CRLF-->
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: #f4f4f4; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"> <span style="color: #0000ff">content</span>: counter(<span style="color: #0000ff">li</span><span style="color: #006080">) ".";</span></pre>
<!--CRLF-->
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: white; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"> <span style="color: #0000ff">counter-increment</span>: <span style="color: #006080">li;</span></pre>
<!--CRLF-->
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: #f4f4f4; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"> <span style="color: #0000ff">position</span>: <span style="color: #006080">absolute;</span></pre>
<!--CRLF-->
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: white; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"> <span style="color: #0000ff">top</span>: <span style="color: #006080">-13px;</span></pre>
<!--CRLF-->
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: #f4f4f4; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"> <span style="color: #0000ff">left</span>: <span style="color: #006080">-50px;</span></pre>
<!--CRLF-->
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: white; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"> <span style="color: #0000ff">color</span>: <span style="color: #006080">#179549;</span></pre>
<!--CRLF-->
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: #f4f4f4; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"> box-sizing: <span style="color: #0000ff">border</span><span style="color: #006080">-box;</span></pre>
<!--CRLF-->
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: white; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"> <span style="color: #0000ff">width</span>: <span style="color: #006080">2em;</span></pre>
<!--CRLF-->
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: #f4f4f4; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"> <span style="color: #0000ff">margin</span>-<span style="color: #0000ff">right</span>: <span style="color: #006080">8px;</span></pre>
<!--CRLF-->
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: white; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"> <span style="color: #0000ff">padding</span>: <span style="color: #006080">4px;</span></pre>
<!--CRLF-->
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: #f4f4f4; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"> <span style="color: #0000ff">font-size</span>: <span style="color: #006080">32px;</span></pre>
<!--CRLF-->
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: white; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"> <span style="color: #0000ff">text-align</span>: <span style="color: #006080">center;</span></pre>
<!--CRLF-->
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: #f4f4f4; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"> <span style="color: #0000ff">font-family</span>: <span style="color: #006080">'AustinWebBoldItalic';</span></pre>
<!--CRLF-->
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: white; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px">}</pre>
<!--CRLF-->
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: #f4f4f4; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"><span style="color: #0000ff">li</span> <span style="color: #0000ff">ol</span></pre>
<!--CRLF-->
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: white; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px">{</pre>
<!--CRLF-->
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: #f4f4f4; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"> <span style="color: #0000ff">margin</span>-<span style="color: #0000ff">top</span>: <span style="color: #006080">6px;</span></pre>
<!--CRLF-->
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: white; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px">}</pre>
<!--CRLF--></div>
</div>
<p>As you can see I use a custom font but that is up to you <img style="border-bottom-style: none; border-left-style: none; border-top-style: none; border-right-style: none" class="wlEmoticon wlEmoticon-smile" alt="Ler" src="/link/819f34e84bfe4a7c8696a0b3b90c178d.png" /></p>
<p><strong>Conclusion: </strong></p>
<p>Making lists look nice in the editor is really simply, use CSS!! The only problem is that if you are tarketing older browsers(IE6) that have not implemented CSS 2.1 you might have a problem.</p>
<p>So start styling your lists and the content produced by editors! Don’t forget that we visits sites for the content.</p>
<p>Byt the way.. I hate when people reset styles using * {margin:0; padding:0;} <img style="border-bottom-style: none; border-left-style: none; border-top-style: none; border-right-style: none" class="wlEmoticon wlEmoticon-winkingsmile" alt="Blinkar" src="/link/a5848d0a65f6486487c1e46a83d2684b.png" /></p>
<p>/Eric</p>
Creating a Dynamic Content plugin for Vimeo and Youtube using Regex
/blogs/Eric-Pettersson/Dates/2011/12/Creating-a-Dynamic-Content-plugin-for-Vimeo-and-Youtube-using-Regex/
2011-12-01T16:50:21.0000000Z
<p>You have probably made a dynamic content plugin before in your projects and using either youtube or another service. But in this case I am using both vimeo and youtube. So the big thing about this is not creating a dynamic content plugin for video but for two using a nice regex. When I got this in my project I thougt it was easy and it should be but the tricky part was greating a nice Regex that could decide if it was a video from youtube or vimeo.</p> <p> </p> <p>So what have i done.. well as I am not a real geek as Ted Nyberg, <a title="http://tedgustaf.com/en/blog/2011/4/creating-dynamic-content-in-episerver-cms-6-r2/" href="http://tedgustaf.com/en/blog/2011/4/creating-dynamic-content-in-episerver-cms-6-r2/">http://tedgustaf.com/en/blog/2011/4/creating-dynamic-content-in-episerver-cms-6-r2/</a>, so I choose the simple way in life and use the EPiServer VS integration stuff. <img style="border-bottom-style: none; border-left-style: none; border-top-style: none; border-right-style: none" class="wlEmoticon wlEmoticon-smile" alt="Ler" src="/link/e832f09ccef44d91ba23164dbe069e72.png" /></p> <p>Rightclick on a folder i VS and add a new EPiServer Dynamic Content like this:</p> <a href="/link/3e83cac9b3de4af79723b8c639db8d0c.png"><img style="background-image: none; border-right-width: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px; padding-top: 0px" title="image" border="0" alt="image" src="/link/84ea7e5037cc42618778c187341653b6.png" width="322" height="203" /></a> <p>When that is done you have a nice usercontrol for dynamic content. Looking something like this in front-end:</p> <div style="border-bottom: silver 1px solid; text-align: left; border-left: silver 1px solid; padding-bottom: 4px; line-height: 12pt; background-color: #f4f4f4; margin: 20px 0px 10px; padding-left: 4px; width: 97.5%; padding-right: 4px; font-family: 'Courier New', courier, monospace; direction: ltr; max-height: 200px; font-size: 8pt; overflow: auto; border-top: silver 1px solid; cursor: text; border-right: silver 1px solid; padding-top: 4px" id="codeSnippetWrapper"> <div style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: #f4f4f4; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px" id="codeSnippet"> <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: white; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"><span style="background-color: #ffff00"><%@ Control Language="C#" AutoEventWireup="true" CodeBehind="dcPlugin.ascx.cs" Inherits="Svanemerket.Templates.Main.Units.Dynamic.dcPlugin" %></span></pre>
<!--CRLF-->
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: #f4f4f4; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"><span style="color: #0000ff"><</span><span style="color: #800000">div</span><span style="color: #0000ff">></span></pre>
<!--CRLF-->
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: white; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"> Add markup for rendering dcPlugin.</pre>
<!--CRLF-->
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: #f4f4f4; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"><span style="color: #0000ff"></</span><span style="color: #800000">div</span><span style="color: #0000ff">></span></pre>
<!--CRLF--></div>
</div>
<p>and like this in back-end:</p>
<div style="border-bottom: silver 1px solid; text-align: left; border-left: silver 1px solid; padding-bottom: 4px; line-height: 12pt; background-color: #f4f4f4; margin: 20px 0px 10px; padding-left: 4px; width: 97.5%; padding-right: 4px; font-family: 'Courier New', courier, monospace; direction: ltr; max-height: 200px; font-size: 8pt; overflow: auto; border-top: silver 1px solid; cursor: text; border-right: silver 1px solid; padding-top: 4px" id="codeSnippetWrapper">
<div style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: #f4f4f4; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px" id="codeSnippet">
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: white; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px">[DynamicContentPlugIn(DisplayName = <span style="color: #006080">"dcPlugin Dynamic Content"</span>, ViewUrl = <span style="color: #006080">"~/Templates/Main/Units/Dynamic/dcPlugin.ascx"</span>)]</pre>
<!--CRLF-->
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: #f4f4f4; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"> <span style="color: #0000ff">public</span> <span style="color: #0000ff">partial</span> <span style="color: #0000ff">class</span> dcPlugin : EPiServer.UserControlBase</pre>
<!--CRLF-->
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: white; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"> {</pre>
<!--CRLF-->
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: #f4f4f4; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"> <span style="color: #cc6633">#region</span> Editable Properties</pre>
<!--CRLF-->
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: white; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"> </pre>
<!--CRLF-->
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: #f4f4f4; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"> <span style="color: #008000">// Add your editable properties as normal .Net properties.</span></pre>
<!--CRLF-->
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: white; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"> <span style="color: #008000">// Supported property types are string, int, bool, </span></pre>
<!--CRLF-->
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: #f4f4f4; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"> <span style="color: #008000">// EPiServer.Core.PageReference and any class</span></pre>
<!--CRLF-->
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: white; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"> <span style="color: #008000">// inheriting EPiServer.Core.PropertyData.</span></pre>
<!--CRLF-->
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: #f4f4f4; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"> </pre>
<!--CRLF-->
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: white; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"> <span style="color: #cc6633">#endregion</span></pre>
<!--CRLF-->
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: #f4f4f4; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"> </pre>
<!--CRLF-->
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: white; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"> <span style="color: #0000ff">protected</span> <span style="color: #0000ff">void</span> Page_Load(<span style="color: #0000ff">object</span> sender, EventArgs e)</pre>
<!--CRLF-->
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: #f4f4f4; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"> {</pre>
<!--CRLF-->
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: white; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"> </pre>
<!--CRLF-->
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: #f4f4f4; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"> }</pre>
<!--CRLF-->
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: white; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"> }</pre>
<!--CRLF--></div>
</div>
<p>so now it is time to add our custom code.</p>
<h2>Add properties on the Dynamic Content settings</h2>
<p>In this plugin I only need one property and that is the string were I enter the url to the video.</p>
<div style="border-bottom: silver 1px solid; text-align: left; border-left: silver 1px solid; padding-bottom: 4px; line-height: 12pt; background-color: #f4f4f4; margin: 20px 0px 10px; padding-left: 4px; width: 97.5%; padding-right: 4px; font-family: 'Courier New', courier, monospace; direction: ltr; max-height: 200px; font-size: 8pt; overflow: auto; border-top: silver 1px solid; cursor: text; border-right: silver 1px solid; padding-top: 4px" id="codeSnippetWrapper">
<div style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: #f4f4f4; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px" id="codeSnippet">
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: white; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"><span style="color: #0000ff">public</span> <span style="color: #0000ff">string</span> Videourl { get; set; }</pre>
<!--CRLF--></div>
</div>
<h2>The Regex</h2>
<p>To handle to diffrent videorurl we need two diffrent Regex. One for Vimeo and one for Youtube.</p>
<div style="border-bottom: silver 1px solid; text-align: left; border-left: silver 1px solid; padding-bottom: 4px; line-height: 12pt; background-color: #f4f4f4; margin: 20px 0px 10px; padding-left: 4px; width: 97.5%; padding-right: 4px; font-family: 'Courier New', courier, monospace; direction: ltr; max-height: 200px; font-size: 8pt; overflow: auto; border-top: silver 1px solid; cursor: text; border-right: silver 1px solid; padding-top: 4px" id="codeSnippetWrapper">
<div style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: #f4f4f4; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px" id="codeSnippet">
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: white; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"><span style="color: #0000ff">public</span> <span style="color: #0000ff">static</span> <span style="color: #0000ff">readonly</span> Regex VimeoVideoRegex = <span style="color: #0000ff">new</span> Regex(<span style="color: #006080">@"vimeo\.com/(?:.*#|.*/videos/)?([0-9]+)"</span>, RegexOptions.IgnoreCase | RegexOptions.Multiline);</pre>
<!--CRLF-->
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: #f4f4f4; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"> <span style="color: #0000ff">public</span> <span style="color: #0000ff">static</span> <span style="color: #0000ff">readonly</span> Regex YoutubeVideoRegex = <span style="color: #0000ff">new</span> Regex(<span style="color: #006080">@"youtu(?:\.be|be\.com)/(?:.*v(?:/|=)|(?:.*/)?)([a-zA-Z0-9-_]+)"</span>, RegexOptions.IgnoreCase);</pre>
<!--CRLF--></div>
</div>
<p>These regex will handle, as far as i can tell, all diffrent links at the moment <img style="border-bottom-style: none; border-left-style: none; border-top-style: none; border-right-style: none" class="wlEmoticon wlEmoticon-smile" alt="Ler" src="/link/e832f09ccef44d91ba23164dbe069e72.png" /> They will be used too decide if we should use the iframe for youtube or for vimeo.</p>
<h2>Creating the Player()</h2>
<p>Here I create diffrent iframes depending on the success of the Regex.</p>
<div style="border-bottom: silver 1px solid; text-align: left; border-left: silver 1px solid; padding-bottom: 4px; line-height: 12pt; background-color: #f4f4f4; margin: 20px 0px 10px; padding-left: 4px; width: 97.5%; padding-right: 4px; font-family: 'Courier New', courier, monospace; direction: ltr; max-height: 200px; font-size: 8pt; overflow: auto; border-top: silver 1px solid; cursor: text; border-right: silver 1px solid; padding-top: 4px" id="codeSnippetWrapper">
<div style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: #f4f4f4; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px" id="codeSnippet">
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: white; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"><span style="color: #0000ff">public</span> <span style="color: #0000ff">string</span> GetPlayer()</pre>
<!--CRLF-->
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: #f4f4f4; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px">{</pre>
<!--CRLF-->
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: white; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"> Match youtubeMatch = YoutubeVideoRegex.Match(Videourl);</pre>
<!--CRLF-->
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: #f4f4f4; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"> Match vimeoMatch = VimeoVideoRegex.Match(Videourl);</pre>
<!--CRLF-->
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: white; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"> <span style="color: #0000ff">string</span> id;</pre>
<!--CRLF-->
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: #f4f4f4; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"> <span style="color: #0000ff">const</span> <span style="color: #0000ff">string</span> vimeoframe = <span style="color: #006080">"<iframe width=\"450\" height=\"315\" src=\"http://player.vimeo.com/video/{0}?title=0&amp;byline=0&amp;portrait=0&amp\" frameborder=\"0\" allowfullscreen></iframe>"</span>;</pre>
<!--CRLF-->
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: white; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"> </pre>
<!--CRLF-->
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: #f4f4f4; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"> <span style="color: #0000ff">const</span> <span style="color: #0000ff">string</span> youtubeframe = <span style="color: #006080">"<iframe width=\"450\" height=\"315\" src=\"http://www.youtube.com/embed/{0}\" frameborder=\"0\" allowfullscreen></iframe>"</span>;</pre>
<!--CRLF-->
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: white; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"> </pre>
<!--CRLF-->
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: #f4f4f4; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"> <span style="color: #0000ff">if</span> (youtubeMatch.Success)</pre>
<!--CRLF-->
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: white; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"> {</pre>
<!--CRLF-->
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: #f4f4f4; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"> id = youtubeMatch.Groups[1].Value;</pre>
<!--CRLF-->
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: white; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"> <span style="color: #0000ff">return</span> <span style="color: #0000ff">string</span>.Format(youtubeframe, id);</pre>
<!--CRLF-->
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: #f4f4f4; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"> }</pre>
<!--CRLF-->
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: white; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"> <span style="color: #0000ff">if</span> (vimeoMatch.Success)</pre>
<!--CRLF-->
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: #f4f4f4; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"> {</pre>
<!--CRLF-->
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: white; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"> id = vimeoMatch.Groups[1].Value;</pre>
<!--CRLF-->
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: #f4f4f4; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"> <span style="color: #0000ff">return</span> <span style="color: #0000ff">string</span>.Format(vimeoframe, id);</pre>
<!--CRLF-->
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: white; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"> </pre>
<!--CRLF-->
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: #f4f4f4; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"> }</pre>
<!--CRLF-->
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: white; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"> <span style="color: #0000ff">return</span> <span style="color: #0000ff">string</span>.Empty;</pre>
<!--CRLF-->
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: #f4f4f4; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px">}</pre>
<!--CRLF--></div>
</div>
<p>Now lets update the front-end so that we actually will render the player.</p>
<div style="border-bottom: silver 1px solid; text-align: left; border-left: silver 1px solid; padding-bottom: 4px; line-height: 12pt; background-color: #f4f4f4; margin: 20px 0px 10px; padding-left: 4px; width: 97.5%; padding-right: 4px; font-family: 'Courier New', courier, monospace; direction: ltr; max-height: 200px; font-size: 8pt; overflow: auto; border-top: silver 1px solid; cursor: text; border-right: silver 1px solid; padding-top: 4px" id="codeSnippetWrapper">
<div style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: #f4f4f4; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px" id="codeSnippet">
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: white; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"><div></pre>
<!--CRLF-->
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: #f4f4f4; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"> <% = GetPlayer() %></pre>
<!--CRLF-->
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: white; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"></div></pre>
<!--CRLF--></div>
</div>
<p>Finally edit a page and insert your new dynaminc content. Copy/paste the url from either vimeo or youtube into the VideoUrl and the result will look something like this..</p>
<p><a href="/link/6b0a74cd9296467f9ea29b57c642991e.png"><img style="background-image: none; border-right-width: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px; padding-top: 0px" title="image" border="0" alt="image" src="/link/2ec7a34d523f4e7bb03e43d6f7689215.png" width="311" height="656" /></a></p>
<p>Thats it! Hopefully this will help someone… <img style="border-bottom-style: none; border-left-style: none; border-top-style: none; border-right-style: none" class="wlEmoticon wlEmoticon-smile" alt="Ler" src="/link/e832f09ccef44d91ba23164dbe069e72.png" /></p>
Trying to upgrading to CMS 6 R2 and getting: You are not authorized to access /PageFiles/!?
/blogs/Eric-Pettersson/Dates/2011/8/Trying-to-upgrading-to-CMS-6-R2-and-getting-You-are-not-authorized-to-access-PageFiles/
2011-08-22T11:43:07.0000000Z
<p>We made an upgrade of a project last week. Everything started on my computer but my collegues could not get their websites to work. And we got this strange message about not having access to /PageFiles/:</p> <div style="border-bottom: silver 1px solid; text-align: left; border-left: silver 1px solid; padding-bottom: 4px; line-height: 12pt; background-color: #f4f4f4; margin: 20px 0px 10px; padding-left: 4px; width: 97.5%; padding-right: 4px; font-family: 'Courier New', courier, monospace; direction: ltr; max-height: 200px; font-size: 8pt; overflow: auto; border-top: silver 1px solid; cursor: text; border-right: silver 1px solid; padding-top: 4px" id="codeSnippetWrapper"> <div style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: #f4f4f4; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px" id="codeSnippet"> <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: white; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px">Server Error in '/' Application.</pre>
<!--CRLF-->
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: #f4f4f4; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px">You are not authorized to access /PageFiles/</pre>
<!--CRLF-->
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: white; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px">Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.</pre>
<!--CRLF-->
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: #f4f4f4; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"> </pre>
<!--CRLF-->
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: white; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px">Exception Details: System.UnauthorizedAccessException: You are not authorized to access /PageFiles/</pre>
<!--CRLF-->
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: #f4f4f4; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"> </pre>
<!--CRLF-->
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: white; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px">ASP.NET is not authorized to access the requested resource. Consider granting access rights to the resource to the ASP.NET request identity. ASP.NET has a base process identity (typically {MACHINE}\ASPNET on IIS 5 or Network Service on IIS 6 and IIS 7, and the configured application pool identity on IIS 7.5) that is used if the application is not impersonating. If the application is impersonating via <span style="color: #0000ff"><</span><span style="color: #800000">identity</span> <span style="color: #ff0000">impersonate</span><span style="color: #0000ff">="true"</span><span style="color: #0000ff">/></span>, the identity will be the anonymous user (typically IUSR_MACHINENAME) or the authenticated request user.</pre>
<!--CRLF-->
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: #f4f4f4; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"> </pre>
<!--CRLF-->
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: white; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px">To grant ASP.NET access to a file, right-click the file in Explorer, choose "Properties" and select the Security tab. Click "Add" to add the appropriate user or group. Highlight the ASP.NET account, and check the boxes for the desired access.</pre>
<!--CRLF-->
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: #f4f4f4; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"> </pre>
<!--CRLF-->
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: white; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px">Source Error:</pre>
<!--CRLF-->
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: #f4f4f4; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"> </pre>
<!--CRLF-->
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: white; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px">An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.</pre>
<!--CRLF-->
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: #f4f4f4; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"> </pre>
<!--CRLF-->
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: white; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px">Stack Trace:</pre>
<!--CRLF-->
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: #f4f4f4; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"> </pre>
<!--CRLF-->
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: white; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px">[UnauthorizedAccessException: You are not authorized to access /PageFiles/]</pre>
<!--CRLF-->
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: #f4f4f4; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"> EPiServer.Web.Hosting.VirtualPathVersioningProvider.GetDirectory(String virtualPath) +547</pre>
<!--CRLF-->
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: white; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"> EPiServer.Web.Hosting.VirtualPathHandler.InitializeProviders(ProviderSettingsCollection providers, Boolean captureCustomExceptions) +1798</pre>
<!--CRLF-->
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: #f4f4f4; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"> EPiServer.Web.InitializationModule.InitializeVirtualPathProviders(VirtualPathElement vpElement) +171</pre>
<!--CRLF-->
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: white; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"> EPiServer.Web.InitializeEngine.Initialize() +516</pre>
<!--CRLF-->
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: #f4f4f4; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"> EPiServer.Web.InitializationModule.Initialize(EPiServerSection config, Settings settings, ConnectionStringSettingsCollection connectionStringSettings) +2150</pre>
<!--CRLF-->
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: white; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"> EPiServer.Web.InitializeEngine.Initialize() +516</pre>
<!--CRLF-->
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: #f4f4f4; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"> EPiServer.Web.InitializationModule.StaticInitialization() +1494</pre>
<!--CRLF-->
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: white; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"> EPiServer.Web.InitializationModule.Initialize(InitializationEngine context) +46</pre>
<!--CRLF-->
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: #f4f4f4; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"> EPiServer.Framework.Initialization.InitializationEngine.InitializeModules() +647</pre>
<!--CRLF-->
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: white; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"> EPiServer.Framework.Initialization.InitializationEngine.Initialize(HostType hostType) +115</pre>
<!--CRLF-->
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: #f4f4f4; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"> EPiServer.Framework.Initialization.InitializationModule.Initialize(HostType hostType) +199</pre>
<!--CRLF-->
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: white; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"> EPiServer.Framework.Initialization.InitializationModule.FrameworkInitialization(HostType hostType) +64</pre>
<!--CRLF-->
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: #f4f4f4; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"> EPiServer.Framework.Initialization.InitializationModule.Application_BeginRequest(Object sender, EventArgs e) +46</pre>
<!--CRLF-->
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: white; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"> System.Web.SyncEventExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() +80</pre>
<!--CRLF-->
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: #f4f4f4; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"> System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) +270</pre>
<!--CRLF-->
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: white; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"> </pre>
<!--CRLF-->
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: #f4f4f4; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"> </pre>
<!--CRLF-->
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: white; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px">Version Information: Microsoft .NET Framework Version:4.0.30319; ASP.NET Version:4.0.30319.225 </pre>
<!--CRLF--></div>
</div>
<p>The solution is <strong>very</strong> simple. <img style="border-bottom-style: none; border-left-style: none; border-top-style: none; border-right-style: none" class="wlEmoticon wlEmoticon-smile" alt="Ler" src="/link/8a278e0a4dfa4034a0801f58672cc542.png" /> Just remember that you have files in a episerverinstallation that you might not have included in your projectfile. Make sure these files also are updated in your source control environment. In this case we forgot to add a new EPiServerFramework.config. In CMS 6 R2 EPiServer adds a new section to this file:</p>
<div style="border-bottom: silver 1px solid; text-align: left; border-left: silver 1px solid; padding-bottom: 4px; line-height: 12pt; background-color: #f4f4f4; margin: 20px 0px 10px; padding-left: 4px; width: 97.5%; padding-right: 4px; font-family: 'Courier New', courier, monospace; direction: ltr; max-height: 200px; font-size: 8pt; overflow: auto; border-top: silver 1px solid; cursor: text; border-right: silver 1px solid; padding-top: 4px" id="codeSnippetWrapper">
<div style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: #f4f4f4; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px" id="codeSnippet">
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: white; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"><span style="color: #0000ff"><</span><span style="color: #800000">virtualRoles</span> <span style="color: #ff0000">replacePrincipal</span><span style="color: #0000ff">="true"</span><span style="color: #0000ff">></span></pre>
<!--CRLF-->
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: #f4f4f4; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"> <span style="color: #0000ff"><</span><span style="color: #800000">providers</span><span style="color: #0000ff">></span></pre>
<!--CRLF-->
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: white; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"> <span style="color: #0000ff"><</span><span style="color: #800000">add</span> <span style="color: #ff0000">name</span><span style="color: #0000ff">="Administrators"</span> <span style="color: #ff0000">type</span><span style="color: #0000ff">="EPiServer.Security.WindowsAdministratorsRole, EPiServer"</span> <span style="color: #0000ff">/></span></pre>
<!--CRLF-->
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: #f4f4f4; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"> <span style="color: #0000ff"><</span><span style="color: #800000">add</span> <span style="color: #ff0000">name</span><span style="color: #0000ff">="Everyone"</span> <span style="color: #ff0000">type</span><span style="color: #0000ff">="EPiServer.Security.EveryoneRole, EPiServer"</span> <span style="color: #0000ff">/></span></pre>
<!--CRLF-->
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: white; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"> <span style="color: #0000ff"><</span><span style="color: #800000">add</span> <span style="color: #ff0000">name</span><span style="color: #0000ff">="Authenticated"</span> <span style="color: #ff0000">type</span><span style="color: #0000ff">="EPiServer.Security.AuthenticatedRole, EPiServer"</span> <span style="color: #0000ff">/></span></pre>
<!--CRLF-->
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: #f4f4f4; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"> <span style="color: #0000ff"><</span><span style="color: #800000">add</span> <span style="color: #ff0000">name</span><span style="color: #0000ff">="Anonymous"</span> <span style="color: #ff0000">type</span><span style="color: #0000ff">="EPiServer.Security.AnonymousRole, EPiServer"</span> <span style="color: #0000ff">/></span></pre>
<!--CRLF-->
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: white; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"> <span style="color: #0000ff"><</span><span style="color: #800000">add</span> <span style="color: #ff0000">name</span><span style="color: #0000ff">="Creator"</span> <span style="color: #ff0000">type</span><span style="color: #0000ff">="EPiServer.Security.CreatorRole, EPiServer"</span> <span style="color: #0000ff">/></span></pre>
<!--CRLF-->
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: #f4f4f4; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"> <span style="color: #0000ff"><</span><span style="color: #800000">add</span> <span style="color: #ff0000">roles</span><span style="color: #0000ff">="WebAdmins, Administrators"</span> <span style="color: #ff0000">mode</span><span style="color: #0000ff">="Any"</span> <span style="color: #ff0000">name</span><span style="color: #0000ff">="CmsAdmins"</span> <span style="color: #ff0000">type</span><span style="color: #0000ff">="EPiServer.Security.MappedRole, EPiServer"</span> <span style="color: #0000ff">/></span></pre>
<!--CRLF-->
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: white; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"> <span style="color: #0000ff"><</span><span style="color: #800000">add</span> <span style="color: #ff0000">roles</span><span style="color: #0000ff">="WebEditors"</span> <span style="color: #ff0000">mode</span><span style="color: #0000ff">="Any"</span> <span style="color: #ff0000">name</span><span style="color: #0000ff">="CmsEditors"</span> <span style="color: #ff0000">type</span><span style="color: #0000ff">="EPiServer.Security.MappedRole, EPiServer"</span> <span style="color: #0000ff">/></span></pre>
<!--CRLF-->
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: #f4f4f4; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"> <span style="color: #0000ff"></</span><span style="color: #800000">providers</span><span style="color: #0000ff">></span></pre>
<!--CRLF-->
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: white; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"><span style="color: #0000ff"></</span><span style="color: #800000">virtualRoles</span><span style="color: #0000ff">></span></pre>
<!--CRLF--></div>
</div>
<p>Make sure this is there otherwise your solution will not start and your /PageFiles/ will get a access denied error. <img style="border-bottom-style: none; border-left-style: none; border-top-style: none; border-right-style: none" class="wlEmoticon wlEmoticon-smile" alt="Ler" src="/link/8a278e0a4dfa4034a0801f58672cc542.png" /></p>