I am using a powershell script to initialize several values of a custom webpart and then insert that webpart onto a page. I have been partially successful using the method below:
$multiPartLeftWebPart = New-Object MultiPart.MultiPart.MultiPart
$multiPartLeftWebPart.CurveEquation = "{""x0"":5,""y0"":-11,""x1"":107,""y1"":-44,""x2"":257,""y2"":-56,""x3"":403,""y3"":-55}"
$multiPartLeftWebPart.SelectedTabs.Add("News")
$multiPartLeftWebPart.SelectedTabs.Add("FAQ")
$multiPartLeftWebPart.SelectedTabs.Add("Events")
In this webpart CurveEquation and SelectedTabs are custom values used by my webpart that are typically set through the editor pane.
My Issue is that when I go into my editor pane after I have run my script only the CurveEquation value is set. CurveEquation is a string and SelectedTabs is a List<string>
object.
I have stepped through my code when the editor part is loading and confirmed that CurveEquation has the expected value and that there are 0 items in Selected tabs.
Do I need to do something special to set values of a List<string>
object using powershell in this way?
Code for the property:
[Personalizable(PersonalizationScope.Shared), WebBrowsable(false)]
public List<String> SelectedTabs
{
get;
set;
}
[XmlElement(ElementName = "SelectedTabs")]
I'm wondering if the webpart isn't serializing properly. – James Love Dec 16 '11 at 8:01