Introduction
By default text properties in the Web Part Property pane can be filled in using a Property Builder as shown below:
This only applies to the default SharePoint ToolPanes (or EditorParts as they're called in the new terminology). If you develop a custom ToolPane or EditorPart with TextBoxes, Labels and such you don't get that Property Builder.
BuilderTextBox
... Introducing the BuilderTextBox ! A free Composite Control that renders a Text Box and Button with the necessary javascript in order to show the text property builder.
Installation and Usage
- Install the BuilderTextBox in the Global Assembly Cache (drag .dll to %systemroot%\assembly)
- Reference the BuilderTextBox assembly in your Visual Studio project
- Use it in your custom Microsoft.SharePoint.WebPartPages.ToolPane or System.Web.UI.WebControls.WebParts.EditorPart
Sample ToolPart
public class DynamicToolPart : Microsoft.SharePoint.WebPartPages.ToolPart
{
private Vandest.BuilderTextBox.BuilderTextBox text1 = null;
public DynamicToolPart()
{
this.Title = "My Custom ToolPart";
}
protected override void CreateChildControls()
{
text1 = new Vandest.BuilderTextBox.BuilderTextBox();
text1.ID = "text1";
text1.Text = this.WebPartToEdit.Description; // Using Description for sample purposes
Controls.Add(text1);
}
public override void ApplyChanges()
{
// Set value of a property in this.WebPartToEdit
// Using Description for sample purposes
this.WebPartToEdit.Description = text1.Text;
base.ApplyChanges();
}
public override void SyncChanges()
{
base.SyncChanges();
}
}
Downloads
-
Compiled assembly
-
Visual Studio 2005 Project
References
Notes
This control was developed for and tested in WSS 3.0 and MOSS 2007.
ToolPart is used in combination with a SharePoint Web Part (Microsoft.SharePoint.WebPartPages.WebPart). If possible use EditorPart in combination with an ASP.NET 2.0 Web Part (System.Web.UI.WebControls.WebParts.WebPart).
Feel free to modify or improve the code.