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've inherited a VB.NET / MOSS 2007 Sharepoint application and have been tasked with adding a new custom Webpart.

I've declared a number of public properties to store configuration data for the webpart, like so:

Public Class CustomWebPart
    Inherits WebPart

    <Personalizable> _
    Public Property PrimaryID() As Int32

    Protected Overrides Sub CreateChildControls()
        MyBase.CreateChildControls()

        Controls.Add(New LiteralControl(PrimaryID.ToString())
    End Sub

End Class

This webpart has been added to a Sharepoint page in the standard way, within a WebPartManager etc..

I've created a custom EditorPart, with which I am able to correctly Sync and Apply changes to these configuration values. My custom EditorPart has the following ApplyChanges method:

Public Overrides Function ApplyChanges() As Boolean
    Dim part = DirectCast(Me.WebPartToEdit, CustomWebPart)
    part.PrimaryID = idSelector.SelectedValue

    part.SetPersonalizationDirty()
End Function

After editing and returning to the page, I see it showing the selected value for my property, and correctly rendering the report as specified in CreateChildControls() (simplified here). However, as soon as I refresh the page, my personalized properties return to their default values.

Here's what I've looked into so far:

  • My account has administrative permissions
  • Webpart is configured for Shared-level personalization (as it should be)
  • Personalization (digging into WebPartManager.Personalization) IsEnabled, IsModifiable, but ProviderName = "" and HasPersonalizationState is uninitialized.
  • Other custom webparts, with seemingly identical code, store personalized properties just fine.

Anyways - I'm at a loss. Thoughts? Happy to provide more code as required. Thanks!

share|improve this question
    
I guess there is some mistake here: <Personalizable> _ Public Property PrimaryID() As Int32, did you try changing to <Personalizable(PersonalizationScope.Shared)> _ –  Arsalan Adam Khatri Dec 2 '12 at 6:59
    
Good call - tried and no dice. –  famousbirds Dec 2 '12 at 23:54
add comment

1 Answer

Update Inadvertently figured this one out while working through an unrelated issue.

I had another property defined as

<Personalizable> Public Property IDs As IEnumerable(Of Int32)

later in the code. Can't serialize an interface though, especially one that represents an in-memory query - so it was killing Personalization altogether on my page. I replaced all my array-type properties with Lists, like so:

<Personalizable> Public Property IDs As List(Of Int32)

And now personalization is working. Hooray!

share|improve this answer
add comment

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.