Skip to main content
replaced http://stackoverflow.com/ with https://stackoverflow.com/
Source Link

You should be able to use a Custom Toolpart.

In thisthis question there is a solution (in the actual question):

public class RichTextToolbarProperty : Microsoft.SharePoint.WebPartPages.ToolPart
    {

        InputFormTextBox textBox;
        Panel toolPartPanel;

        protected override void CreateChildControls()
        {
            toolPartPanel = new Panel();
            toolPartPanel.GroupingText = "Default text here";
            textBox = new InputFormTextBox();
            textBox.TextMode = TextBoxMode.MultiLine;
            textBox.Rows = 10;
            textBox.RichText = true;
            textBox.RichTextMode = SPRichTextMode.FullHtml;

            BasePublicationWebPart wp = (BasePublicationWebPart)this.ParentToolPane.SelectedWebPart;
            textBox.Text = wp.DefaultText;

            toolPartPanel.Controls.Add(textBox);
            Controls.Add(toolPartPanel);
            base.CreateChildControls();
        }

        public override void ApplyChanges()
        {
            BasePublicationWebPart wp = (BasePublicationWebPart)this.ParentToolPane.SelectedWebPart;
            wp.DefaultText = textBox.Text;
        }

    }

and in the webpart:

public abstract class BasePublicationWebPart : Microsoft.SharePoint.WebPartPages.WebPart
{

    public string DefaultText
    {
        get
        {
            return _defaultText;
        }
        set { _defaultText = value; }
    }

    public override ToolPart[] GetToolParts()
    {

        ToolPart[] allToolParts = new ToolPart[3];
        WebPartToolPart standardToolParts = new WebPartToolPart();
        CustomPropertyToolPart customToolParts = new CustomPropertyToolPart(); 

        allToolParts[0] = standardToolParts;
        allToolParts[1] = customToolParts;
        allToolParts[2] = new MyCustomProperty.RichTextToolbarProperty(); 

        return allToolParts;
    }

You should be able to use a Custom Toolpart.

In this question there is a solution (in the actual question):

public class RichTextToolbarProperty : Microsoft.SharePoint.WebPartPages.ToolPart
    {

        InputFormTextBox textBox;
        Panel toolPartPanel;

        protected override void CreateChildControls()
        {
            toolPartPanel = new Panel();
            toolPartPanel.GroupingText = "Default text here";
            textBox = new InputFormTextBox();
            textBox.TextMode = TextBoxMode.MultiLine;
            textBox.Rows = 10;
            textBox.RichText = true;
            textBox.RichTextMode = SPRichTextMode.FullHtml;

            BasePublicationWebPart wp = (BasePublicationWebPart)this.ParentToolPane.SelectedWebPart;
            textBox.Text = wp.DefaultText;

            toolPartPanel.Controls.Add(textBox);
            Controls.Add(toolPartPanel);
            base.CreateChildControls();
        }

        public override void ApplyChanges()
        {
            BasePublicationWebPart wp = (BasePublicationWebPart)this.ParentToolPane.SelectedWebPart;
            wp.DefaultText = textBox.Text;
        }

    }

and in the webpart:

public abstract class BasePublicationWebPart : Microsoft.SharePoint.WebPartPages.WebPart
{

    public string DefaultText
    {
        get
        {
            return _defaultText;
        }
        set { _defaultText = value; }
    }

    public override ToolPart[] GetToolParts()
    {

        ToolPart[] allToolParts = new ToolPart[3];
        WebPartToolPart standardToolParts = new WebPartToolPart();
        CustomPropertyToolPart customToolParts = new CustomPropertyToolPart(); 

        allToolParts[0] = standardToolParts;
        allToolParts[1] = customToolParts;
        allToolParts[2] = new MyCustomProperty.RichTextToolbarProperty(); 

        return allToolParts;
    }

You should be able to use a Custom Toolpart.

In this question there is a solution (in the actual question):

public class RichTextToolbarProperty : Microsoft.SharePoint.WebPartPages.ToolPart
    {

        InputFormTextBox textBox;
        Panel toolPartPanel;

        protected override void CreateChildControls()
        {
            toolPartPanel = new Panel();
            toolPartPanel.GroupingText = "Default text here";
            textBox = new InputFormTextBox();
            textBox.TextMode = TextBoxMode.MultiLine;
            textBox.Rows = 10;
            textBox.RichText = true;
            textBox.RichTextMode = SPRichTextMode.FullHtml;

            BasePublicationWebPart wp = (BasePublicationWebPart)this.ParentToolPane.SelectedWebPart;
            textBox.Text = wp.DefaultText;

            toolPartPanel.Controls.Add(textBox);
            Controls.Add(toolPartPanel);
            base.CreateChildControls();
        }

        public override void ApplyChanges()
        {
            BasePublicationWebPart wp = (BasePublicationWebPart)this.ParentToolPane.SelectedWebPart;
            wp.DefaultText = textBox.Text;
        }

    }

and in the webpart:

public abstract class BasePublicationWebPart : Microsoft.SharePoint.WebPartPages.WebPart
{

    public string DefaultText
    {
        get
        {
            return _defaultText;
        }
        set { _defaultText = value; }
    }

    public override ToolPart[] GetToolParts()
    {

        ToolPart[] allToolParts = new ToolPart[3];
        WebPartToolPart standardToolParts = new WebPartToolPart();
        CustomPropertyToolPart customToolParts = new CustomPropertyToolPart(); 

        allToolParts[0] = standardToolParts;
        allToolParts[1] = customToolParts;
        allToolParts[2] = new MyCustomProperty.RichTextToolbarProperty(); 

        return allToolParts;
    }
Source Link
Robert Lindgren
  • 24.5k
  • 12
  • 53
  • 79

You should be able to use a Custom Toolpart.

In this question there is a solution (in the actual question):

public class RichTextToolbarProperty : Microsoft.SharePoint.WebPartPages.ToolPart
    {

        InputFormTextBox textBox;
        Panel toolPartPanel;

        protected override void CreateChildControls()
        {
            toolPartPanel = new Panel();
            toolPartPanel.GroupingText = "Default text here";
            textBox = new InputFormTextBox();
            textBox.TextMode = TextBoxMode.MultiLine;
            textBox.Rows = 10;
            textBox.RichText = true;
            textBox.RichTextMode = SPRichTextMode.FullHtml;

            BasePublicationWebPart wp = (BasePublicationWebPart)this.ParentToolPane.SelectedWebPart;
            textBox.Text = wp.DefaultText;

            toolPartPanel.Controls.Add(textBox);
            Controls.Add(toolPartPanel);
            base.CreateChildControls();
        }

        public override void ApplyChanges()
        {
            BasePublicationWebPart wp = (BasePublicationWebPart)this.ParentToolPane.SelectedWebPart;
            wp.DefaultText = textBox.Text;
        }

    }

and in the webpart:

public abstract class BasePublicationWebPart : Microsoft.SharePoint.WebPartPages.WebPart
{

    public string DefaultText
    {
        get
        {
            return _defaultText;
        }
        set { _defaultText = value; }
    }

    public override ToolPart[] GetToolParts()
    {

        ToolPart[] allToolParts = new ToolPart[3];
        WebPartToolPart standardToolParts = new WebPartToolPart();
        CustomPropertyToolPart customToolParts = new CustomPropertyToolPart(); 

        allToolParts[0] = standardToolParts;
        allToolParts[1] = customToolParts;
        allToolParts[2] = new MyCustomProperty.RichTextToolbarProperty(); 

        return allToolParts;
    }