<?xml version="1.0" encoding="utf-8"?><feed xmlns="http://www.w3.org/2005/Atom"><title type="text">Blog posts by Kalle Hoppe</title><link href="http://world.optimizely.com" /><updated>2009-08-31T14:40:54.0000000Z</updated><id>https://world.optimizely.com/blogs/Kalle-Hoppe/</id> <generator uri="http://world.optimizely.com" version="2.0">Optimizely World</generator> <entry><title>Is page in Edit mode</title><link href="http://www.ninjacoding.net/archive/2009/08/31/is-page-in-edit-mode.aspx" /><id>&lt;p&gt;I’m writing an account registering control. This control needs to show the user how to register for a new account. But when modifying this control the pages editors must be able to see the hole flow. So I went looking for a smart way to display the control in two ways depending on the context it’s being viewed in. I found &lt;a href=&quot;http://labs.episerver.com/en/Blogs/Jacob-Khan/Dates/2009/8/Am-I-in-Edit-or-View-mode/&quot;&gt;Jacob Khan’s&lt;/a&gt; blog post in &lt;a href=&quot;http://labs.episerver.com/en/Blogs/&quot;&gt;EPiServer labs&lt;/a&gt; that seemed nice but I didn’t get it to work.&lt;/p&gt;  &lt;p&gt;The thing I ended doing was to get the id from the query string, and parsing it to a PageReference to check if it contains a workID. The ID in the QueryString has both the pages ID and the current version being edited, for example 1563_1234 where 1563 is the pages ID and 1234 is the current version. &lt;/p&gt;  &lt;p&gt;If the QueryString contains a work page ID it means that I&#39;m currently looking at a draft, not the published page, hence I&#180;m in Edit mode. &lt;/p&gt;  &lt;p&gt;When getting the WorkID of a PageData object that&#39;s published you will get 0 as a result, and that&#39;s what I&#39;m testing against. &lt;/p&gt;  &lt;p&gt;Here is the code    &lt;br /&gt;&lt;/p&gt;  &lt;pre class=&quot;language-csharp&quot;&gt;&lt;code&gt;public bool IsPageInEditMode
{
    get
    {
        PageReference pageVersionReference = PageReference.Parse(Request.QueryString[&quot;id&quot;]);
        if (pageVersionReference.WorkID &amp;gt; 0)
            return true;
        return false;
    }
}&lt;/code&gt;&lt;/pre&gt;

&lt;div style=&quot;padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px&quot; id=&quot;scid:0767317B-992E-4b12-91E0-4F059A8CECA8:88ccf082-6d87-421f-a893-0af4774a7302&quot; class=&quot;wlWriterEditableSmartContent&quot;&gt;Technorati-taggar: &lt;a href=&quot;http://technorati.com/tags/.net+development&quot; rel=&quot;tag&quot;&gt;.net development&lt;/a&gt;,&lt;a href=&quot;http://technorati.com/tags/EPiServer&quot; rel=&quot;tag&quot;&gt;EPiServer&lt;/a&gt;&lt;/div&gt;&lt;img src=&quot;http://www.ninjacoding.net/aggbug/53.aspx&quot; width=&quot;1&quot; height=&quot;1&quot; /&gt;</id><updated>2009-08-31T14:40:54.0000000Z</updated><summary type="html">Blog post</summary></entry></feed>