1

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?

1

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.

1
  • Sound like a plan. I will try this one.
    – Ievgen
    Dec 3 '12 at 19:53
0

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

So its better to store data somewhere else.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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