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 want to allow a user to store personal information in my WebPart.

So I have a property:

 [WebBrowsable(true)]
 [WebDisplayName("Tag")]
 [Pages.SPWebCategoryName("Tag to display")]
 [Pages.WebPartStorage(Pages.Storage.Personal)]
 [WebDescription("You would put the description here.")]
 [Personalizable(PersonalizationScope.User)]
 public string Tag { get; set; }

The customer wants to update the Tag property in the SharePoint WebPart directly on "OK" button click!

protected void OnButtonClick(...)
{
    var text = tb.Text;
    this.WebPart.Tag = text;
    // How to store?
}

How do I save the information for a specific user?

share|improve this question

2 Answers 2

up vote 1 down vote accepted

Try the following in your click event:

  • Get the limitedwebpartmanager for the current page, in whichever scope you wish
  • ask that webpartmanager for the webpart with the id == this.ID (aka, this webpart)
  • edit the property
  • webpartmanager.savechanges(webpart);

You'll need to refresh the page but I believe that should work to set the property for the web part.

share|improve this answer
    
Sound like a plan. I will try this one. –  Evgeny Dec 3 '12 at 19:53

This is bad solution because each user should check in page on self after each update.

So its better to store data somewhere else.

share|improve this answer

Your Answer

 
discard

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.