How can i make a brows开发者_运维问答able web part property which should be visible only to the Administrator and not to the normal users ?
I was thinking you could do this by creating your own version of WebBrowsableAttribute, (eg AdminOnlyWebBrowsableAttribute) and decorating your property with the custom version.
However, unfortunately the WebBrowsableAttribute class is sealed.
The best alternative I can think of is to create your own EditorPart so that you can control which properties are available to each user,
Go to the modify Shared webpart and uncheck the property Allow Editing in Personal View which comes under advanced.
What attributes are you adding to the property being displayed in the editor? If you are only using [WebBrowsable(true)], the property will be personalizable for all users.
If you only want the property to be set by the admin in the shared scope, you should include a [WebPartStorage(Storage.Shared)] attribute.
See MSDN for more detail.
精彩评论