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 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;
    }
share|improve this question
    
In the public property of the webpart for SelectedTabs, do you have an XmlElement attribute defined? –  James Love Dec 15 '11 at 21:58
    
No I don't, should I? –  Abe Miessler Dec 15 '11 at 23:00
    
I've updated my question to show the code for the property that is not getting set. –  Abe Miessler Dec 15 '11 at 23:01
    
Yeah, I' try with [XmlElement(ElementName = "SelectedTabs")] I'm wondering if the webpart isn't serializing properly. –  James Love Dec 16 '11 at 8:01

Your Answer

 
discard

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

Browse other questions tagged or ask your own question.