Detecting the Personalized View of a Publishing Page
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’s not the case! Instead, Web Part manager handles this.
To accomplish this, do the following in your Web Part:
[CSharp]
if (WebPartManager.GetCurrentWebPartManager(this.Page).Personalization.Scope == PersonalizationScope.User)
{
this.Label1.Text = “In personalized view”;
}
[/CSharp]
Obviously, if you wanted to target the shared view, you could change PersonalizationScope.User to PersonalizationScope.Shared in your if condition.
While you are in each scope , it’s easy to toggle to the other one using the WebPartPersonalization.ToggleScope method.