2

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!

2
  • I guess there is some mistake here: <Personalizable> _ Public Property PrimaryID() As Int32, did you try changing to <Personalizable(PersonalizationScope.Shared)> _ Dec 2, 2012 at 6:59
  • Good call - tried and no dice. Dec 2, 2012 at 23:54

1 Answer 1

1

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!

1
  • Please mark this as answer if your problem is solved. Thanks! May 3, 2014 at 19:43

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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