Take the 2-minute tour ×
SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. It's 100% free, no registration required.

I would like to persist some information entered via my web part so the next time the same user uses it, the settings will be pre-populated.

In the Windows world, I would just slap the data is HKCU, but in the brave new world I have no idea what to to.

I have written some code to store values at the SPFarm level, but I can't seem to figure out the site level.

Any advice?

Thanks.

share|improve this question
add comment

3 Answers

Do you have a button on the web part to save the property? If so, just write the data to a public property on the web part with it's PersonalizationScope set to User. Thus, the property will be stored against the user.

share|improve this answer
add comment

You can use an SPPersistedObject on SPFarm or SPWebApplication level. The PropertyBag can be used on sites via SPWeb.Properties. But I would not store user-specific data in either of these stores. I would go with James' suggestion or put the data in a SQL database...

share|improve this answer
add comment

If you have SharePoint Server you could try using the UserProfile class and creating a custom profile property with your preferences.

Links: Technet, MSDN.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.