<?xml version="1.0" encoding="utf-8"?><feed xmlns="http://www.w3.org/2005/Atom"><title type="text">Blog posts by dataguy</title><link href="http://world.optimizely.com" /><updated>2010-11-08T14:54:00.0000000Z</updated><id>https://world.optimizely.com/blogs/dataguy/</id> <generator uri="http://world.optimizely.com" version="2.0">Optimizely World</generator> <entry><title>.net user controls – stop using String.Split() instead use ParseChildren</title><link href="http://dataguycouk.blogspot.com/2010/11/episerver-net-user-controls-stop-using.html" /><id>Last year a bright young developer (actually he was my senior) asked why I was not using ParseChildren as a cleaner way of parsing data into a .NET user control.&lt;br /&gt;Still struggling I found an article&amp;nbsp; &lt;a href=&quot;http://bchavez.bitarmory.com/archive/2008/07/27/parsechildren-persistchildren-persistencemode.innerproperty.aspx&quot; target=&quot;_blank&quot;&gt;here&lt;/a&gt; which helped a lot. You can also check out MSDN &lt;a href=&quot;http://msdn.microsoft.com/en-us/library/system.web.ui.parsechildrenattribute.aspx&quot; target=&quot;_blank&quot;&gt;here&lt;/a&gt; &lt;br /&gt;&lt;br /&gt;We call the football.ascx in the calling aspx file&amp;nbsp; &lt;br /&gt;&lt;br /&gt;&lt;div id=&quot;codeSnippetWrapper&quot; style=&quot;background-color: #f4f4f4; border-bottom: silver 1px solid; border-left: silver 1px solid; border-right: silver 1px solid; border-top: silver 1px solid; cursor: text; direction: ltr; font-family: &#39;Courier New&#39;, courier, monospace; font-size: 8pt; line-height: 12pt; margin: 20px 0px 10px; max-height: 200px; overflow: auto; padding-bottom: 4px; padding-left: 4px; padding-right: 4px; padding-top: 4px; text-align: left; width: 97.5%;&quot;&gt;&lt;div id=&quot;codeSnippet&quot; style=&quot;background-color: #f4f4f4; border-bottom-style: none; border-left-style: none; border-right-style: none; border-top-style: none; color: black; direction: ltr; font-family: &#39;Courier New&#39;, courier, monospace; font-size: 8pt; line-height: 12pt; overflow: visible; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; text-align: left; width: 100%;&quot;&gt;&lt;pre style=&quot;background-color: white; border-bottom-style: none; border-left-style: none; border-right-style: none; border-top-style: none; color: black; direction: ltr; font-family: &#39;Courier New&#39;, courier, monospace; font-size: 8pt; line-height: 12pt; margin: 0em; overflow: visible; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; text-align: left; width: 100%;&quot;&gt;&amp;lt;uc2:FootballTeams ID=&lt;span style=&quot;color: #006080;&quot;&gt;&quot;MyTeams&quot;&lt;/span&gt; runat=&lt;span style=&quot;color: #006080;&quot;&gt;&quot;server&quot;&lt;/span&gt; &amp;gt;&lt;/pre&gt;&lt;pre style=&quot;background-color: #f4f4f4; border-bottom-style: none; border-left-style: none; border-right-style: none; border-top-style: none; color: black; direction: ltr; font-family: &#39;Courier New&#39;, courier, monospace; font-size: 8pt; line-height: 12pt; margin: 0em; overflow: visible; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; text-align: left; width: 100%;&quot;&gt;&amp;lt;Teams&amp;gt;&lt;/pre&gt;&lt;pre style=&quot;background-color: white; border-bottom-style: none; border-left-style: none; border-right-style: none; border-top-style: none; color: black; direction: ltr; font-family: &#39;Courier New&#39;, courier, monospace; font-size: 8pt; line-height: 12pt; margin: 0em; overflow: visible; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; text-align: left; width: 100%;&quot;&gt;&amp;lt;uc2:Team name=&lt;span style=&quot;color: #006080;&quot;&gt;&quot;Man Utd&quot;&lt;/span&gt; /&amp;gt;&lt;/pre&gt;&lt;pre style=&quot;background-color: #f4f4f4; border-bottom-style: none; border-left-style: none; border-right-style: none; border-top-style: none; color: black; direction: ltr; font-family: &#39;Courier New&#39;, courier, monospace; font-size: 8pt; line-height: 12pt; margin: 0em; overflow: visible; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; text-align: left; width: 100%;&quot;&gt;&amp;lt;uc2:Team name=&lt;span style=&quot;color: #006080;&quot;&gt;&quot;Chelsea&quot;&lt;/span&gt; /&amp;gt;&lt;/pre&gt;&lt;pre style=&quot;background-color: white; border-bottom-style: none; border-left-style: none; border-right-style: none; border-top-style: none; color: black; direction: ltr; font-family: &#39;Courier New&#39;, courier, monospace; font-size: 8pt; line-height: 12pt; margin: 0em; overflow: visible; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; text-align: left; width: 100%;&quot;&gt;&amp;lt;/Teams&amp;gt;&lt;/pre&gt;&lt;pre style=&quot;background-color: #f4f4f4; border-bottom-style: none; border-left-style: none; border-right-style: none; border-top-style: none; color: black; direction: ltr; font-family: &#39;Courier New&#39;, courier, monospace; font-size: 8pt; line-height: 12pt; margin: 0em; overflow: visible; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; text-align: left; width: 100%;&quot;&gt;&amp;lt;/uc2:FootballTeams&amp;gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;&lt;br /&gt;Here is where the work is done.&amp;nbsp; Couple of things if you set ChildrenAsProperties=false you can render groups of controls instead of properties. As a footnote&amp;nbsp;base.Render(writer) outputs the markup in the football.ascx.cs file of the the user control.&lt;br /&gt;&lt;a href=&quot;http://lh5.ggpht.com/_V7rdKcalWLQ/TNghlWt_XLI/AAAAAAAAAHg/HLq62icqx2M/s1600-h/image18%5B2%5D.png&quot;&gt;&lt;img alt=&quot;image&quot; border=&quot;0&quot; height=&quot;565&quot; src=&quot;http://lh6.ggpht.com/_V7rdKcalWLQ/TNgBIvvTwWI/AAAAAAAAAHk/Ncqzc0A8npM/image18_thumb%5B1%5D.png?imgmax=800&quot; style=&quot;border-bottom: 0px; border-left: 0px; border-right: 0px; border-top: 0px; display: inline;&quot; title=&quot;image&quot; width=&quot;492&quot; /&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;Below shows the local variables available from the code behind in the calling aspx file &lt;br /&gt;&lt;br /&gt;&lt;a href=&quot;http://lh3.ggpht.com/_V7rdKcalWLQ/TNgBJPui0NI/AAAAAAAAAHY/rtAB-zd0k84/s1600-h/image%5B43%5D.png&quot;&gt;&lt;img alt=&quot;image&quot; border=&quot;0&quot; height=&quot;290&quot; src=&quot;http://lh4.ggpht.com/_V7rdKcalWLQ/TNgBJrLd6CI/AAAAAAAAAHc/MFDa_ZuvNTs/image_thumb%5B31%5D.png?imgmax=800&quot; style=&quot;border-bottom-width: 0px; border-left-width: 0px; border-right-width: 0px; border-top-width: 0px; display: inline;&quot; title=&quot;image&quot; width=&quot;459&quot; /&gt;&lt;/a&gt;&lt;div class=&quot;blogger-post-footer&quot;&gt;&lt;img width=&quot;1&quot; height=&quot;1&quot; src=&quot;https://blogger.googleusercontent.com/tracker/2877457808808659002-518227326360521005?l=dataguycouk.blogspot.com&quot; alt=&quot;&quot; /&gt;&lt;/div&gt;</id><updated>2010-11-08T14:54:00.0000000Z</updated><summary type="html">Blog post</summary></entry> <entry><title>Save editors from breaking the PageTree</title><link href="http://dataguycouk.blogspot.com/2010/11/episerver-cms-6-sdk-save-editors-from.html" /><id>I was on a project where editors were dragging EPiServer Pages all over the Page Tree. This behaviour broke the application several times because there was also a lack of error trapping. Fair play it was a new EPiServer team and we were all finding our way.&lt;br /&gt;&lt;br /&gt;There are a number of&amp;nbsp; EPiServer.DataFactory events that can help us here. For a full list refer to the SDK DataFactor members section.&lt;br /&gt;&lt;br /&gt;In the example below I have placed the logic in global.asax which can be used to enforce business rules for creation of a page. &lt;br /&gt;&lt;br /&gt;&lt;div id=&quot;codeSnippetWrapper&quot; style=&quot;background-color: #f4f4f4; border-bottom: silver 1px solid; border-left: silver 1px solid; border-right: silver 1px solid; border-top: silver 1px solid; cursor: text; direction: ltr; font-family: &#39;Courier New&#39;, courier, monospace; font-size: 8pt; line-height: 12pt; margin: 20px 0px 10px; max-height: 200px; overflow: auto; padding-bottom: 4px; padding-left: 4px; padding-right: 4px; padding-top: 4px; text-align: left; width: 97.5%;&quot;&gt;&lt;div id=&quot;codeSnippet&quot; style=&quot;background-color: #f4f4f4; border-bottom-style: none; border-left-style: none; border-right-style: none; border-top-style: none; color: black; direction: ltr; font-family: &#39;Courier New&#39;, courier, monospace; font-size: 8pt; line-height: 12pt; overflow: visible; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; text-align: left; width: 100%;&quot;&gt;&lt;pre style=&quot;background-color: white; border-bottom-style: none; border-left-style: none; border-right-style: none; border-top-style: none; color: black; direction: ltr; font-family: &#39;Courier New&#39;, courier, monospace; font-size: 8pt; height: 16px; line-height: 12pt; margin: 0em; overflow: visible; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; text-align: left; width: 156.58%;&quot;&gt;&lt;span style=&quot;color: blue;&quot;&gt;public&lt;/span&gt; &lt;span style=&quot;color: blue;&quot;&gt;class&lt;/span&gt; Global : EPiServer.Global&lt;/pre&gt;&lt;pre style=&quot;background-color: #f4f4f4; border-bottom-style: none; border-left-style: none; border-right-style: none; border-top-style: none; color: black; direction: ltr; font-family: &#39;Courier New&#39;, courier, monospace; font-size: 8pt; line-height: 12pt; margin: 0em; overflow: visible; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; text-align: left; width: 100%;&quot;&gt;{&lt;/pre&gt;&lt;pre style=&quot;background-color: white; border-bottom-style: none; border-left-style: none; border-right-style: none; border-top-style: none; color: black; direction: ltr; font-family: &#39;Courier New&#39;, courier, monospace; font-size: 8pt; height: 16px; line-height: 12pt; margin: 0em; overflow: visible; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; text-align: left; width: 163.07%;&quot;&gt;&lt;span style=&quot;color: blue;&quot;&gt;protected&lt;/span&gt; &lt;span style=&quot;color: blue;&quot;&gt;void&lt;/span&gt; Application_Start(Object sender, EventArgs e)&lt;/pre&gt;&lt;pre style=&quot;background-color: #f4f4f4; border-bottom-style: none; border-left-style: none; border-right-style: none; border-top-style: none; color: black; direction: ltr; font-family: &#39;Courier New&#39;, courier, monospace; font-size: 8pt; line-height: 12pt; margin: 0em; overflow: visible; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; text-align: left; width: 100%;&quot;&gt;{&lt;/pre&gt;&lt;pre style=&quot;background-color: white; border-bottom-style: none; border-left-style: none; border-right-style: none; border-top-style: none; color: black; direction: ltr; font-family: &#39;Courier New&#39;, courier, monospace; font-size: 8pt; height: 17px; line-height: 12pt; margin: 0em; overflow: visible; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; text-align: left; width: 168.23%;&quot;&gt;DataFactory.Instance.CreatingPage += &lt;span style=&quot;color: blue;&quot;&gt;new&lt;/span&gt; PageEventHandler(OnCreatingPage);&lt;/pre&gt;&lt;pre style=&quot;background-color: #f4f4f4; border-bottom-style: none; border-left-style: none; border-right-style: none; border-top-style: none; color: black; direction: ltr; font-family: &#39;Courier New&#39;, courier, monospace; font-size: 8pt; height: 16px; line-height: 12pt; margin: 0em; overflow: visible; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; text-align: left; width: 157.42%;&quot;&gt;}&lt;/pre&gt;&lt;pre style=&quot;background-color: white; border-bottom-style: none; border-left-style: none; border-right-style: none; border-top-style: none; color: black; direction: ltr; font-family: &#39;Courier New&#39;, courier, monospace; font-size: 8pt; height: 12px; line-height: 12pt; margin: 0em; overflow: visible; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; text-align: left; width: 100.2%;&quot;&gt;&lt;/pre&gt;&lt;pre style=&quot;background-color: #f4f4f4; border-bottom-style: none; border-left-style: none; border-right-style: none; border-top-style: none; color: black; direction: ltr; font-family: &#39;Courier New&#39;, courier, monospace; font-size: 8pt; height: 16px; line-height: 12pt; margin: 0em; overflow: visible; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; text-align: left; width: 162.42%;&quot;&gt;&lt;span style=&quot;color: blue;&quot;&gt;public&lt;/span&gt; &lt;span style=&quot;color: blue;&quot;&gt;void&lt;/span&gt; OnCreatingPage(&lt;span style=&quot;color: blue;&quot;&gt;object&lt;/span&gt; sender, PageEventArgs e)&lt;/pre&gt;&lt;pre style=&quot;background-color: white; border-bottom-style: none; border-left-style: none; border-right-style: none; border-top-style: none; color: black; direction: ltr; font-family: &#39;Courier New&#39;, courier, monospace; font-size: 8pt; line-height: 12pt; margin: 0em; overflow: visible; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; text-align: left; width: 100%;&quot;&gt;{&lt;/pre&gt;&lt;pre style=&quot;background-color: #f4f4f4; border-bottom-style: none; border-left-style: none; border-right-style: none; border-top-style: none; color: black; direction: ltr; font-family: &#39;Courier New&#39;, courier, monospace; font-size: 8pt; height: 16px; line-height: 12pt; margin: 0em; overflow: visible; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; text-align: left; width: 171.17%;&quot;&gt;&lt;span style=&quot;color: green;&quot;&gt;// place your validation logic here       &lt;/span&gt;&lt;/pre&gt;&lt;pre style=&quot;background-color: white; border-bottom-style: none; border-left-style: none; border-right-style: none; border-top-style: none; color: black; direction: ltr; font-family: &#39;Courier New&#39;, courier, monospace; font-size: 8pt; height: 16px; line-height: 12pt; margin: 0em; overflow: visible; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; text-align: left; width: 156.15%;&quot;&gt;&lt;span style=&quot;color: green;&quot;&gt;//&lt;/span&gt;&lt;/pre&gt;&lt;pre style=&quot;background-color: #f4f4f4; border-bottom-style: none; border-left-style: none; border-right-style: none; border-top-style: none; color: black; direction: ltr; font-family: &#39;Courier New&#39;, courier, monospace; font-size: 8pt; height: 16px; line-height: 12pt; margin: 0em; overflow: visible; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; text-align: left; width: 165.79%;&quot;&gt;&lt;span style=&quot;color: green;&quot;&gt;//  e.CancelAction = true;  &lt;/span&gt;&lt;/pre&gt;&lt;pre style=&quot;background-color: white; border-bottom-style: none; border-left-style: none; border-right-style: none; border-top-style: none; color: black; direction: ltr; font-family: &#39;Courier New&#39;, courier, monospace; font-size: 8pt; height: 16px; line-height: 12pt; margin: 0em; overflow: visible; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; text-align: left; width: 172.03%;&quot;&gt;&lt;span style=&quot;color: green;&quot;&gt;//  e.CancelReason = &quot;Sorry you can&#39;t create this Page Type here&quot;;&lt;/span&gt;&lt;/pre&gt;&lt;pre style=&quot;background-color: #f4f4f4; border-bottom-style: none; border-left-style: none; border-right-style: none; border-top-style: none; color: black; direction: ltr; font-family: &#39;Courier New&#39;, courier, monospace; font-size: 8pt; height: 1px; line-height: 12pt; margin: 0em; overflow: visible; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; text-align: left; width: 162.04%;&quot;&gt;&lt;/pre&gt;&lt;pre style=&quot;background-color: white; border-bottom-style: none; border-left-style: none; border-right-style: none; border-top-style: none; color: black; direction: ltr; font-family: &#39;Courier New&#39;, courier, monospace; font-size: 8pt; line-height: 12pt; margin: 0em; overflow: visible; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; text-align: left; width: 100%;&quot;&gt;}&lt;/pre&gt;&lt;pre style=&quot;background-color: #f4f4f4; border-bottom-style: none; border-left-style: none; border-right-style: none; border-top-style: none; color: black; direction: ltr; font-family: &#39;Courier New&#39;, courier, monospace; font-size: 8pt; line-height: 12pt; margin: 0em; overflow: visible; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; text-align: left; width: 100%;&quot;&gt;}&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;Using the PageEventsArgs e we can expose the necessary intellisense properties to cancel the action. The CancelReason is the Exception message which can be caught by a try catch block wrapped around the method call that was used to try and create page.&lt;br /&gt;&lt;br /&gt;In the below example we set the Text property of Button1 with the e.CancelReason from global.asax. &lt;br /&gt;&lt;br /&gt;&lt;div id=&quot;codeSnippetWrapper&quot; style=&quot;background-color: #f4f4f4; border-bottom: silver 1px solid; border-left: silver 1px solid; border-right: silver 1px solid; border-top: silver 1px solid; cursor: text; direction: ltr; font-family: &#39;Courier New&#39;, courier, monospace; font-size: 8pt; line-height: 12pt; margin: 20px 0px 10px; max-height: 200px; overflow: auto; padding-bottom: 4px; padding-left: 4px; padding-right: 4px; padding-top: 4px; text-align: left; width: 97.5%;&quot;&gt;&lt;div id=&quot;codeSnippet&quot; style=&quot;background-color: #f4f4f4; border-bottom-style: none; border-left-style: none; border-right-style: none; border-top-style: none; color: black; direction: ltr; font-family: &#39;Courier New&#39;, courier, monospace; font-size: 8pt; line-height: 12pt; overflow: visible; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; text-align: left; width: 100%;&quot;&gt;&lt;pre style=&quot;background-color: white; border-bottom-style: none; border-left-style: none; border-right-style: none; border-top-style: none; color: black; direction: ltr; font-family: &#39;Courier New&#39;, courier, monospace; font-size: 8pt; line-height: 12pt; margin: 0em; overflow: visible; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; text-align: left; width: 100%;&quot;&gt;&lt;span style=&quot;color: blue;&quot;&gt;try&lt;/span&gt;&lt;/pre&gt;&lt;pre style=&quot;background-color: #f4f4f4; border-bottom-style: none; border-left-style: none; border-right-style: none; border-top-style: none; color: black; direction: ltr; font-family: &#39;Courier New&#39;, courier, monospace; font-size: 8pt; line-height: 12pt; margin: 0em; overflow: visible; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; text-align: left; width: 100%;&quot;&gt;{&lt;/pre&gt;&lt;pre style=&quot;background-color: white; border-bottom-style: none; border-left-style: none; border-right-style: none; border-top-style: none; color: black; direction: ltr; font-family: &#39;Courier New&#39;, courier, monospace; font-size: 8pt; height: 32px; line-height: 12pt; margin: 0em; overflow: visible; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; text-align: left; width: 168.46%;&quot;&gt;DataFactory.Instance.Save(myNewPageData, DataAccess.SaveAction.Publish, Security.AccessLevel.NoAccess);&lt;/pre&gt;&lt;pre style=&quot;background-color: #f4f4f4; border-bottom-style: none; border-left-style: none; border-right-style: none; border-top-style: none; color: black; direction: ltr; font-family: &#39;Courier New&#39;, courier, monospace; font-size: 8pt; line-height: 12pt; margin: 0em; overflow: visible; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; text-align: left; width: 100%;&quot;&gt;}&lt;/pre&gt;&lt;pre style=&quot;background-color: white; border-bottom-style: none; border-left-style: none; border-right-style: none; border-top-style: none; color: black; direction: ltr; font-family: &#39;Courier New&#39;, courier, monospace; font-size: 8pt; line-height: 12pt; margin: 0em; overflow: visible; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; text-align: left; width: 100%;&quot;&gt;&lt;span style=&quot;color: blue;&quot;&gt;catch&lt;/span&gt; (Exception ex)&lt;/pre&gt;&lt;pre style=&quot;background-color: #f4f4f4; border-bottom-style: none; border-left-style: none; border-right-style: none; border-top-style: none; color: black; direction: ltr; font-family: &#39;Courier New&#39;, courier, monospace; font-size: 8pt; line-height: 12pt; margin: 0em; overflow: visible; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; text-align: left; width: 100%;&quot;&gt;{&lt;/pre&gt;&lt;pre style=&quot;background-color: white; border-bottom-style: none; border-left-style: none; border-right-style: none; border-top-style: none; color: black; direction: ltr; font-family: &#39;Courier New&#39;, courier, monospace; font-size: 8pt; line-height: 12pt; margin: 0em; overflow: visible; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; text-align: left; width: 100%;&quot;&gt;Button1.Text = ex.Message;&lt;/pre&gt;&lt;pre style=&quot;background-color: #f4f4f4; border-bottom-style: none; border-left-style: none; border-right-style: none; border-top-style: none; color: black; direction: ltr; font-family: &#39;Courier New&#39;, courier, monospace; font-size: 8pt; line-height: 12pt; margin: 0em; overflow: visible; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; text-align: left; width: 100%;&quot;&gt;&lt;span style=&quot;color: blue;&quot;&gt;return&lt;/span&gt;;&lt;/pre&gt;&lt;pre style=&quot;background-color: white; border-bottom-style: none; border-left-style: none; border-right-style: none; border-top-style: none; color: black; direction: ltr; font-family: &#39;Courier New&#39;, courier, monospace; font-size: 8pt; line-height: 12pt; margin: 0em; overflow: visible; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; text-align: left; width: 100%;&quot;&gt;}&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;There lots of events you can use in this way all you have to do is refer to the EPiServer CMS 6 SDK DataFactory members.&lt;div class=&quot;blogger-post-footer&quot;&gt;&lt;img width=&quot;1&quot; height=&quot;1&quot; src=&quot;https://blogger.googleusercontent.com/tracker/2877457808808659002-228226429751689378?l=dataguycouk.blogspot.com&quot; alt=&quot;&quot; /&gt;&lt;/div&gt;</id><updated>2010-11-04T10:02:00.0000000Z</updated><summary type="html">Blog post</summary></entry> <entry><title>Creating multiple language pages</title><link href="http://dataguycouk.blogspot.com/2010/11/episerver-cms-60-sdk-create-language.html" /><id>For this example I am using&amp;nbsp;Public Templates demo from &lt;a href=&quot;http://world.episerver.com/&quot;&gt;http://world.episerver.com/&lt;/a&gt; as my base.&lt;br /&gt;&lt;br /&gt;In the code snippet below two EPiServer pages are created based on the [Public] Standard page. One for English and the second one for Swedish&lt;br /&gt;&lt;div id=&quot;codeSnippetWrapper&quot; style=&quot;background-color: #f4f4f4; border-bottom: silver 1px solid; border-left: silver 1px solid; border-right: silver 1px solid; border-top: silver 1px solid; cursor: text; direction: ltr; font-family: &#39;Courier New&#39;, courier, monospace; font-size: 8pt; height: 290px; line-height: 12pt; margin: 20px 0px 10px; max-height: 200px; overflow: auto; padding-bottom: 4px; padding-left: 4px; padding-right: 4px; padding-top: 4px; text-align: left; width: 97.26%;&quot;&gt;&lt;div id=&quot;codeSnippet&quot; style=&quot;background-color: #f4f4f4; border-bottom-style: none; border-left-style: none; border-right-style: none; border-top-style: none; color: black; direction: ltr; font-family: &#39;Courier New&#39;, courier, monospace; font-size: 8pt; line-height: 12pt; overflow: visible; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; text-align: left; width: 100%;&quot;&gt;&lt;pre style=&quot;background-color: white; border-bottom-style: none; border-left-style: none; border-right-style: none; border-top-style: none; color: black; direction: ltr; font-family: &#39;Courier New&#39;, courier, monospace; font-size: 8pt; height: 32px; line-height: 12pt; margin: 0em; overflow: visible; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; text-align: left; width: 205.56%;&quot;&gt;&lt;span style=&quot;color: blue;&quot;&gt;public&lt;/span&gt; &lt;span style=&quot;color: blue;&quot;&gt;enum&lt;/span&gt; KnownPageID : &lt;span style=&quot;color: blue;&quot;&gt;int&lt;/span&gt; { StartPage = 26, ExampleRootBranch = 39 }&lt;/pre&gt;&lt;pre style=&quot;background-color: #f4f4f4; border-bottom-style: none; border-left-style: none; border-right-style: none; border-top-style: none; color: black; direction: ltr; font-family: &#39;Courier New&#39;, courier, monospace; font-size: 8pt; height: 16px; line-height: 12pt; margin: 0em; overflow: visible; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; text-align: left; width: 215.37%;&quot;&gt;&lt;span style=&quot;color: blue;&quot;&gt;protected&lt;/span&gt; &lt;span style=&quot;color: blue;&quot;&gt;void&lt;/span&gt; Button1_Click(&lt;span style=&quot;color: blue;&quot;&gt;object&lt;/span&gt; sender, EventArgs e)&lt;/pre&gt;&lt;pre style=&quot;background-color: white; border-bottom-style: none; border-left-style: none; border-right-style: none; border-top-style: none; color: black; direction: ltr; font-family: &#39;Courier New&#39;, courier, monospace; font-size: 8pt; line-height: 12pt; margin: 0em; overflow: visible; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; text-align: left; width: 100%;&quot;&gt;{           &lt;/pre&gt;&lt;pre style=&quot;background-color: #f4f4f4; border-bottom-style: none; border-left-style: none; border-right-style: none; border-top-style: none; color: black; direction: ltr; font-family: &#39;Courier New&#39;, courier, monospace; font-size: 8pt; height: 17px; line-height: 12pt; margin: 0em; overflow: visible; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; text-align: left; width: 209.89%;&quot;&gt;var myPageData = DataFactory.Instance.GetPage(&lt;span style=&quot;color: blue;&quot;&gt;new&lt;/span&gt; PageReference((&lt;span style=&quot;color: blue;&quot;&gt;int&lt;/span&gt;)KnownPageID.ExampleRootBranch));&lt;/pre&gt;&lt;pre style=&quot;background-color: white; border-bottom-style: none; border-left-style: none; border-right-style: none; border-top-style: none; color: black; direction: ltr; font-family: &#39;Courier New&#39;, courier, monospace; font-size: 8pt; height: 14px; line-height: 12pt; margin: 0em; overflow: visible; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; text-align: left; width: 211.31%;&quot;&gt;var myNewPageData = DataFactory.Instance.GetDefaultPageData(myPageData.PageLink, &lt;span style=&quot;color: #006080;&quot;&gt;&quot;[Public] Standard page&quot;&lt;/span&gt;);&lt;/pre&gt;&lt;pre style=&quot;background-color: #f4f4f4; border-bottom-style: none; border-left-style: none; border-right-style: none; border-top-style: none; color: black; direction: ltr; font-family: &#39;Courier New&#39;, courier, monospace; font-size: 8pt; line-height: 12pt; margin: 0em; overflow: visible; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; text-align: left; width: 100%;&quot;&gt;myNewPageData.PageName = &lt;span style=&quot;color: #006080;&quot;&gt;&quot;New page (en)&quot;&lt;/span&gt;;&lt;/pre&gt;&lt;pre style=&quot;background-color: white; border-bottom-style: none; border-left-style: none; border-right-style: none; border-top-style: none; color: black; direction: ltr; font-family: &#39;Courier New&#39;, courier, monospace; font-size: 8pt; height: 23px; line-height: 12pt; margin: 0em; overflow: visible; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; text-align: left; width: 218.7%;&quot;&gt;DataFactory.Instance.Save(myNewPageData, DataAccess.SaveAction.Publish, Security.AccessLevel.NoAccess);&lt;/pre&gt;&lt;pre style=&quot;background-color: #f4f4f4; border-bottom-style: none; border-left-style: none; border-right-style: none; border-top-style: none; color: black; direction: ltr; font-family: &#39;Courier New&#39;, courier, monospace; font-size: 8pt; line-height: 12pt; margin: 0em; overflow: visible; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; text-align: left; width: 100%;&quot;&gt;&amp;nbsp;&lt;/pre&gt;&lt;pre style=&quot;background-color: white; border-bottom-style: none; border-left-style: none; border-right-style: none; border-top-style: none; color: black; direction: ltr; font-family: &#39;Courier New&#39;, courier, monospace; font-size: 8pt; height: 18px; line-height: 12pt; margin: 0em; overflow: visible; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; text-align: left; width: 204.23%;&quot;&gt;var newLanguageBranch = DataFactory.Instance.CreateLanguageBranch(myNewPageData.PageLink, &lt;span style=&quot;color: blue;&quot;&gt;new&lt;/span&gt; LanguageSelector(&lt;span style=&quot;color: #006080;&quot;&gt;&quot;sv&quot;&lt;/span&gt;));&lt;/pre&gt;&lt;pre style=&quot;background-color: #f4f4f4; border-bottom-style: none; border-left-style: none; border-right-style: none; border-top-style: none; color: black; direction: ltr; font-family: &#39;Courier New&#39;, courier, monospace; font-size: 8pt; height: 16px; line-height: 12pt; margin: 0em; overflow: visible; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; text-align: left; width: 197.86%;&quot;&gt;newLanguageBranch.PageName = &lt;span style=&quot;color: #006080;&quot;&gt;&quot;Nytt sida (sv)&quot;&lt;/span&gt;;&lt;/pre&gt;&lt;pre style=&quot;background-color: white; border-bottom-style: none; border-left-style: none; border-right-style: none; border-top-style: none; color: black; direction: ltr; font-family: &#39;Courier New&#39;, courier, monospace; font-size: 8pt; height: 1px; line-height: 12pt; margin: 0em; overflow: visible; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; text-align: left; width: 191.26%;&quot;&gt;&amp;nbsp;&lt;/pre&gt;&lt;pre style=&quot;background-color: #f4f4f4; border-bottom-style: none; border-left-style: none; border-right-style: none; border-top-style: none; color: black; direction: ltr; font-family: &#39;Courier New&#39;, courier, monospace; font-size: 8pt; height: 16px; line-height: 12pt; margin: 0em; overflow: visible; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; text-align: left; width: 193.8%;&quot;&gt;&lt;span style=&quot;color: blue;&quot;&gt;try&lt;/span&gt;&lt;/pre&gt;&lt;pre style=&quot;background-color: white; border-bottom-style: none; border-left-style: none; border-right-style: none; border-top-style: none; color: black; direction: ltr; font-family: &#39;Courier New&#39;, courier, monospace; font-size: 8pt; line-height: 12pt; margin: 0em; overflow: visible; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; text-align: left; width: 100%;&quot;&gt;{&lt;/pre&gt;&lt;pre style=&quot;background-color: #f4f4f4; border-bottom-style: none; border-left-style: none; border-right-style: none; border-top-style: none; color: black; direction: ltr; font-family: &#39;Courier New&#39;, courier, monospace; font-size: 8pt; height: 15px; line-height: 12pt; margin: 0em; overflow: visible; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; text-align: left; width: 230.2%;&quot;&gt;DataFactory.Instance.Save(newLanguageBranch, DataAccess.SaveAction.Publish, Security.AccessLevel.NoAccess);&lt;/pre&gt;&lt;pre style=&quot;background-color: white; border-bottom-style: none; border-left-style: none; border-right-style: none; border-top-style: none; color: black; direction: ltr; font-family: &#39;Courier New&#39;, courier, monospace; font-size: 8pt; line-height: 12pt; margin: 0em; overflow: visible; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; text-align: left; width: 100%;&quot;&gt;}&lt;/pre&gt;&lt;pre style=&quot;background-color: #f4f4f4; border-bottom-style: none; border-left-style: none; border-right-style: none; border-top-style: none; color: black; direction: ltr; font-family: &#39;Courier New&#39;, courier, monospace; font-size: 8pt; height: 16px; line-height: 12pt; margin: 0em; overflow: visible; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; text-align: left; width: 158.1%;&quot;&gt;&lt;span style=&quot;color: blue;&quot;&gt;catch&lt;/span&gt; (Exception ex)&lt;/pre&gt;&lt;pre style=&quot;background-color: white; border-bottom-style: none; border-left-style: none; border-right-style: none; border-top-style: none; color: black; direction: ltr; font-family: &#39;Courier New&#39;, courier, monospace; font-size: 8pt; line-height: 12pt; margin: 0em; overflow: visible; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; text-align: left; width: 100%;&quot;&gt;{&lt;/pre&gt;&lt;pre style=&quot;background-color: #f4f4f4; border-bottom-style: none; border-left-style: none; border-right-style: none; border-top-style: none; color: black; direction: ltr; font-family: &#39;Courier New&#39;, courier, monospace; font-size: 8pt; height: 16px; line-height: 12pt; margin: 0em; overflow: visible; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; text-align: left; width: 154.94%;&quot;&gt;&lt;span style=&quot;color: blue;&quot;&gt;throw&lt;/span&gt; ex;&lt;/pre&gt;&lt;pre style=&quot;background-color: white; border-bottom-style: none; border-left-style: none; border-right-style: none; border-top-style: none; color: black; direction: ltr; font-family: &#39;Courier New&#39;, courier, monospace; font-size: 8pt; height: 16px; line-height: 12pt; margin: 0em; overflow: visible; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; text-align: left; width: 169.1%;&quot;&gt;}&lt;/pre&gt;&lt;pre style=&quot;background-color: #f4f4f4; border-bottom-style: none; border-left-style: none; border-right-style: none; border-top-style: none; color: black; direction: ltr; font-family: &#39;Courier New&#39;, courier, monospace; font-size: 8pt; line-height: 12pt; margin: 0em; overflow: visible; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; text-align: left; width: 100%;&quot;&gt;}&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;blogger-post-footer&quot;&gt;&lt;img width=&quot;1&quot; height=&quot;1&quot; src=&quot;https://blogger.googleusercontent.com/tracker/2877457808808659002-3587584944083723888?l=dataguycouk.blogspot.com&quot; alt=&quot;&quot; /&gt;&lt;/div&gt;</id><updated>2010-11-03T16:55:00.0000000Z</updated><summary type="html">Blog post</summary></entry></feed>