{"id":1079,"date":"2011-08-02T18:22:27","date_gmt":"2011-08-02T23:22:27","guid":{"rendered":"http:\/\/blogs.devhorizon.com\/reza\/?p=1079"},"modified":"2011-08-02T18:32:51","modified_gmt":"2011-08-02T23:32:51","slug":"detecting-the-personalized-view-of-a-publishing-page","status":"publish","type":"post","link":"https:\/\/blogs.devhorizon.com\/reza\/2011\/08\/02\/detecting-the-personalized-view-of-a-publishing-page\/","title":{"rendered":"Detecting the Personalized View of a Publishing Page"},"content":{"rendered":"<p>The requirement is pretty straightforward : Show a coaching statement in each Web Part placed in the personalized view (personalized view != shared view).<\/p>\n<p>One would imagine that <a href=\"http:\/\/msdn.microsoft.com\/en-us\/library\/microsoft.sharepoint.webcontrols.spcontrolmode%28v=office.12%29.aspx\">SPContext.Current.FormContext.FormMode<\/a> would let you detect if a page is put in the personalized view, but that&#8217;s not the case! Instead, Web Part manager handles this.<\/p>\n<p>To accomplish this, do the following in your Web Part:<\/p>\n<p>[CSharp]<br \/>\nif (WebPartManager.GetCurrentWebPartManager(this.Page).Personalization.Scope == PersonalizationScope.User)<br \/>\n{<br \/>\n  this.Label1.Text = &#8220;In personalized view&#8221;;<br \/>\n}<br \/>\n[\/CSharp]<\/p>\n<p>Obviously, if you wanted to target the shared view, you could change PersonalizationScope.User to PersonalizationScope.Shared in your if condition.<\/p>\n<p><a href=\"https:\/\/blogs.devhorizon.com\/reza\/wp-content\/uploads\/2011\/08\/personalized.png\" title=\"personalized.png\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/blogs.devhorizon.com\/reza\/wp-content\/uploads\/2011\/08\/personalized.png\" alt=\"personalized.png\" width=\"429\" height=\"164\" \/><\/a><\/p>\n<p><a href=\"https:\/\/blogs.devhorizon.com\/reza\/wp-content\/uploads\/2011\/08\/shared.png\" title=\"shared.png\"><img decoding=\"async\" src=\"https:\/\/blogs.devhorizon.com\/reza\/wp-content\/uploads\/2011\/08\/shared.png\" alt=\"shared.png\" \/><\/a><\/p>\n<p>While you are in each scope , it&#8217;s easy to toggle to the other one using the <a href=\"http:\/\/msdn.microsoft.com\/en-us\/library\/system.web.ui.webcontrols.webparts.webpartpersonalization.togglescope%28v=vs.90%29.aspx\">WebPartPersonalization.ToggleScope<\/a> method.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>The requirement is pretty straightforward : Show a coaching statement in each Web Part placed in the personalized view (personalized view != shared view). One would imagine that SPContext.Current.FormContext.FormMode would let you detect if a page is put in the personalized view, but that&#8217;s not the case! Instead, Web Part manager handles this. To accomplish [&hellip;]<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[36],"tags":[],"class_list":["post-1079","post","type-post","status-publish","format-standard","hentry","category-sharepoint-2010"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v27.3 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>Detecting the Personalized View of a Publishing Page - Reza Alirezaei&#039;s Blog %<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/blogs.devhorizon.com\/reza\/2011\/08\/02\/detecting-the-personalized-view-of-a-publishing-page\/\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Reza Alirezaei\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"1 minute\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\\\/\\\/blogs.devhorizon.com\\\/reza\\\/2011\\\/08\\\/02\\\/detecting-the-personalized-view-of-a-publishing-page\\\/#article\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/blogs.devhorizon.com\\\/reza\\\/2011\\\/08\\\/02\\\/detecting-the-personalized-view-of-a-publishing-page\\\/\"},\"author\":{\"name\":\"Reza Alirezaei\",\"@id\":\"https:\\\/\\\/blogs.devhorizon.com\\\/reza\\\/#\\\/schema\\\/person\\\/cdbb24d283697a65951cb4a14e474938\"},\"headline\":\"Detecting the Personalized View of a Publishing Page\",\"datePublished\":\"2011-08-02T23:22:27+00:00\",\"dateModified\":\"2011-08-02T23:32:51+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/blogs.devhorizon.com\\\/reza\\\/2011\\\/08\\\/02\\\/detecting-the-personalized-view-of-a-publishing-page\\\/\"},\"wordCount\":131,\"commentCount\":3,\"image\":{\"@id\":\"https:\\\/\\\/blogs.devhorizon.com\\\/reza\\\/2011\\\/08\\\/02\\\/detecting-the-personalized-view-of-a-publishing-page\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/blogs.devhorizon.com\\\/reza\\\/wp-content\\\/uploads\\\/2011\\\/08\\\/personalized.png\",\"articleSection\":[\"SharePoint 2010\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\\\/\\\/blogs.devhorizon.com\\\/reza\\\/2011\\\/08\\\/02\\\/detecting-the-personalized-view-of-a-publishing-page\\\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/blogs.devhorizon.com\\\/reza\\\/2011\\\/08\\\/02\\\/detecting-the-personalized-view-of-a-publishing-page\\\/\",\"url\":\"https:\\\/\\\/blogs.devhorizon.com\\\/reza\\\/2011\\\/08\\\/02\\\/detecting-the-personalized-view-of-a-publishing-page\\\/\",\"name\":\"Detecting the Personalized View of a Publishing Page - Reza Alirezaei's Blog %\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/blogs.devhorizon.com\\\/reza\\\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\\\/\\\/blogs.devhorizon.com\\\/reza\\\/2011\\\/08\\\/02\\\/detecting-the-personalized-view-of-a-publishing-page\\\/#primaryimage\"},\"image\":{\"@id\":\"https:\\\/\\\/blogs.devhorizon.com\\\/reza\\\/2011\\\/08\\\/02\\\/detecting-the-personalized-view-of-a-publishing-page\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/blogs.devhorizon.com\\\/reza\\\/wp-content\\\/uploads\\\/2011\\\/08\\\/personalized.png\",\"datePublished\":\"2011-08-02T23:22:27+00:00\",\"dateModified\":\"2011-08-02T23:32:51+00:00\",\"author\":{\"@id\":\"https:\\\/\\\/blogs.devhorizon.com\\\/reza\\\/#\\\/schema\\\/person\\\/cdbb24d283697a65951cb4a14e474938\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/blogs.devhorizon.com\\\/reza\\\/2011\\\/08\\\/02\\\/detecting-the-personalized-view-of-a-publishing-page\\\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/blogs.devhorizon.com\\\/reza\\\/2011\\\/08\\\/02\\\/detecting-the-personalized-view-of-a-publishing-page\\\/#primaryimage\",\"url\":\"https:\\\/\\\/blogs.devhorizon.com\\\/reza\\\/wp-content\\\/uploads\\\/2011\\\/08\\\/personalized.png\",\"contentUrl\":\"https:\\\/\\\/blogs.devhorizon.com\\\/reza\\\/wp-content\\\/uploads\\\/2011\\\/08\\\/personalized.png\",\"width\":448,\"height\":169},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/blogs.devhorizon.com\\\/reza\\\/#website\",\"url\":\"https:\\\/\\\/blogs.devhorizon.com\\\/reza\\\/\",\"name\":\"Reza Alirezaei's Blog\",\"description\":\"Blogging from the field!\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\\\/\\\/blogs.devhorizon.com\\\/reza\\\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Person\",\"@id\":\"https:\\\/\\\/blogs.devhorizon.com\\\/reza\\\/#\\\/schema\\\/person\\\/cdbb24d283697a65951cb4a14e474938\",\"name\":\"Reza Alirezaei\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/3ba940d84e0ecb909e62e93df4c56daf0395c7e53c914467ab2ee73124a7d7b6?s=96&d=mm&r=g\",\"url\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/3ba940d84e0ecb909e62e93df4c56daf0395c7e53c914467ab2ee73124a7d7b6?s=96&d=mm&r=g\",\"contentUrl\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/3ba940d84e0ecb909e62e93df4c56daf0395c7e53c914467ab2ee73124a7d7b6?s=96&d=mm&r=g\",\"caption\":\"Reza Alirezaei\"},\"url\":\"https:\\\/\\\/blogs.devhorizon.com\\\/reza\\\/author\\\/rezaa\\\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Detecting the Personalized View of a Publishing Page - Reza Alirezaei's Blog %","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/blogs.devhorizon.com\/reza\/2011\/08\/02\/detecting-the-personalized-view-of-a-publishing-page\/","twitter_misc":{"Written by":"Reza Alirezaei","Est. reading time":"1 minute"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/blogs.devhorizon.com\/reza\/2011\/08\/02\/detecting-the-personalized-view-of-a-publishing-page\/#article","isPartOf":{"@id":"https:\/\/blogs.devhorizon.com\/reza\/2011\/08\/02\/detecting-the-personalized-view-of-a-publishing-page\/"},"author":{"name":"Reza Alirezaei","@id":"https:\/\/blogs.devhorizon.com\/reza\/#\/schema\/person\/cdbb24d283697a65951cb4a14e474938"},"headline":"Detecting the Personalized View of a Publishing Page","datePublished":"2011-08-02T23:22:27+00:00","dateModified":"2011-08-02T23:32:51+00:00","mainEntityOfPage":{"@id":"https:\/\/blogs.devhorizon.com\/reza\/2011\/08\/02\/detecting-the-personalized-view-of-a-publishing-page\/"},"wordCount":131,"commentCount":3,"image":{"@id":"https:\/\/blogs.devhorizon.com\/reza\/2011\/08\/02\/detecting-the-personalized-view-of-a-publishing-page\/#primaryimage"},"thumbnailUrl":"https:\/\/blogs.devhorizon.com\/reza\/wp-content\/uploads\/2011\/08\/personalized.png","articleSection":["SharePoint 2010"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/blogs.devhorizon.com\/reza\/2011\/08\/02\/detecting-the-personalized-view-of-a-publishing-page\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/blogs.devhorizon.com\/reza\/2011\/08\/02\/detecting-the-personalized-view-of-a-publishing-page\/","url":"https:\/\/blogs.devhorizon.com\/reza\/2011\/08\/02\/detecting-the-personalized-view-of-a-publishing-page\/","name":"Detecting the Personalized View of a Publishing Page - Reza Alirezaei's Blog %","isPartOf":{"@id":"https:\/\/blogs.devhorizon.com\/reza\/#website"},"primaryImageOfPage":{"@id":"https:\/\/blogs.devhorizon.com\/reza\/2011\/08\/02\/detecting-the-personalized-view-of-a-publishing-page\/#primaryimage"},"image":{"@id":"https:\/\/blogs.devhorizon.com\/reza\/2011\/08\/02\/detecting-the-personalized-view-of-a-publishing-page\/#primaryimage"},"thumbnailUrl":"https:\/\/blogs.devhorizon.com\/reza\/wp-content\/uploads\/2011\/08\/personalized.png","datePublished":"2011-08-02T23:22:27+00:00","dateModified":"2011-08-02T23:32:51+00:00","author":{"@id":"https:\/\/blogs.devhorizon.com\/reza\/#\/schema\/person\/cdbb24d283697a65951cb4a14e474938"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/blogs.devhorizon.com\/reza\/2011\/08\/02\/detecting-the-personalized-view-of-a-publishing-page\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/blogs.devhorizon.com\/reza\/2011\/08\/02\/detecting-the-personalized-view-of-a-publishing-page\/#primaryimage","url":"https:\/\/blogs.devhorizon.com\/reza\/wp-content\/uploads\/2011\/08\/personalized.png","contentUrl":"https:\/\/blogs.devhorizon.com\/reza\/wp-content\/uploads\/2011\/08\/personalized.png","width":448,"height":169},{"@type":"WebSite","@id":"https:\/\/blogs.devhorizon.com\/reza\/#website","url":"https:\/\/blogs.devhorizon.com\/reza\/","name":"Reza Alirezaei's Blog","description":"Blogging from the field!","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/blogs.devhorizon.com\/reza\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Person","@id":"https:\/\/blogs.devhorizon.com\/reza\/#\/schema\/person\/cdbb24d283697a65951cb4a14e474938","name":"Reza Alirezaei","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/secure.gravatar.com\/avatar\/3ba940d84e0ecb909e62e93df4c56daf0395c7e53c914467ab2ee73124a7d7b6?s=96&d=mm&r=g","url":"https:\/\/secure.gravatar.com\/avatar\/3ba940d84e0ecb909e62e93df4c56daf0395c7e53c914467ab2ee73124a7d7b6?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/3ba940d84e0ecb909e62e93df4c56daf0395c7e53c914467ab2ee73124a7d7b6?s=96&d=mm&r=g","caption":"Reza Alirezaei"},"url":"https:\/\/blogs.devhorizon.com\/reza\/author\/rezaa\/"}]}},"_links":{"self":[{"href":"https:\/\/blogs.devhorizon.com\/reza\/wp-json\/wp\/v2\/posts\/1079","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/blogs.devhorizon.com\/reza\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blogs.devhorizon.com\/reza\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blogs.devhorizon.com\/reza\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/blogs.devhorizon.com\/reza\/wp-json\/wp\/v2\/comments?post=1079"}],"version-history":[{"count":0,"href":"https:\/\/blogs.devhorizon.com\/reza\/wp-json\/wp\/v2\/posts\/1079\/revisions"}],"wp:attachment":[{"href":"https:\/\/blogs.devhorizon.com\/reza\/wp-json\/wp\/v2\/media?parent=1079"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blogs.devhorizon.com\/reza\/wp-json\/wp\/v2\/categories?post=1079"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blogs.devhorizon.com\/reza\/wp-json\/wp\/v2\/tags?post=1079"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}