I am looking to add custom properties to a tool part. I've been able to add the textbox as desired. I've been able to enter values and display it in the webpart.

The problem is when I edit the webpart - the panel pops up but the control I added is not populated with the previously entered value. See below:

Why doesn't this work? :(

I have followed the instructions on this website exactly as written - neither myself nor a more experienced Sharepoint developer co-worker is able to figure out what's going on here.

We thought that overriding the SyncChanges() method would allow for this - It seems it doesn't, unless our implementation isn't correct?

    public override void SyncChanges()
        DemoWebPart wp = (DemoWebPart)this.ParentToolPane.SelectedWebPart;
        urls.Text = wp.ListValue;

We have also prefixed the urls property of the DemoWebPart.cs class with the following, to no avail:

    [Browsable(true), Category("Miscellaneous"),
    DefaultValue("Site Names"),
    WebPartStorage(Storage.Shared / Personal / None),
    FriendlyName("URLs"), Description("Text Property")]

(Having tried Storage.Shared, Storage.Personal, and Storage.None).

Any help you can provide would be greatly appreciated - thanks in advance!

1 Answer 1


When I have done the same I have always set the values of the custom property controls inside the ToolPart's CreateChildControls method to the corresponding values of the properties in the WebPart.

protected override void CreateChildControls()
   (MyWebPart) wp = (MyWebPart) this.ParentToolPane.SelectedWebPart;

   TextBox t = new TextBox();
   t.Text = wp.CustomTextProperty; // Set value to the webpart property

This seems to work fine.

  • +1. To add: you can find some examples of how to deal with toolparts, in the following opensource project: enhancedwebpart.codeplex.com Commented Jan 24, 2012 at 17:55
  • Thank you robwilliams, those two lines were missing. Adding them in resolved the issue!
    – splatto
    Commented Jan 24, 2012 at 18:39

Your Answer

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

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