Attention: We are retiring the ASP.NET Community Blogs. Learn more >

Personalization Scope

I was working on a site in which I had to implement webparts. The problem which I faced was I could only allow the admin to change the layout of the page (positioning of webparts) and that updated layout must be visible to all users.
 
Working with webparts we require WebpartManager who manages all the webparts. There is a property of WebpartManager which is called Scope, it is a read only property. There are two types of scopes that are PersonalizationScope.User and PersonalizationScope.Shared. PersonalizationScope is an enumeration for the two scopes.
 
If you are using personalization all the changes made will only be visible to that particular user who made those changes, because when user logs in it enters into PersonalizationScope.User and the changes will not be visible to anyone else. What to do if we have above mentioned scenario in which only one user can make changes and it will be visible to everyone.
 
in the Form_Load even try to do this.
 
if (this.WebpartManager1.Personalization.Scope==PersonalizationScope.User)
     this.WebpartManager1.Personalization.ToggleScope();
 
ToggleScope() method will invert this scope if it is User then it will change it to Shared or vice versa.
 
In this case if the user logs in who have rights to change out will enter in Shared mode and all the changes he made will be visible to all users.
 
You will be required to add following attribute in the webconfig's webpart tag which is bold
 
<webParts>
.
. //webParts other settings

<authorization>
<
allow verbs="enterSharedScope" users="*"
/>
</
authorization
>
.
.

</personalization>

</webParts>

2 Comments

Comments have been disabled for this content.