views:

129

answers:

1

Hi,

I got to store some user specific data (string) in my sharepoint webpart.I guess hidden webpart properties should do the trick. Tried with the following attributes on webpart property:

[WebBrowsable(false)] [Bindable(true)] [WebPartStorage(Storage.Personal)] [Personalizable(PersonalizationScope.User)]

But i observe in the webpart that data stored is not user specific. Any help?

Thanx

A: 

How are you reading your data ? You can use the WebPart.PartCacheRead method to retrieve per use values.

web.config can be modified to signal how you want your WebPartCache to be stored. To support caching in database then you must include the [Serializable()] attribute to you custom classes

The WebPart.EffectiveStorage property can also help in determining how the data is stored:

if (EffectiveStorage == Storage.Shared)
{
    output.Write("<b>You are now in shared mode.</b>");
}

Just wondering why you have WebBrowsable attribute set as false. Are the users not able to configure the web part ? When and how is the property value set ?

armannvg
Hi, Sorry for late reply. I actually have to user selected data from a drop down. This drop selection needs to be retained when user comes back to site. WebBrowsable is set to false because i dont want the user to see the webpart property. Just store the drop down selected value in webpart property
John3030
Just a thought, you could use a property bag from the SPWeb object (http://msdn.microsoft.com/en-us/library/ee413763.aspx) but that's originally thought for complex objects and might be overkill in your case
armannvg