Today I needed a RichText editor in a sharepoint webpart, so after some googling and using the reflector I found a class in the Microsoft.SharePoint.WebControls namespace that fits my needs, InputFormTextBox!
The control is not well documented (the same as all other controls in the Microsoft.SharePoint.WebControls namespace) but it's quite easy to use:
InputFormTextBox richTextEditor = new InputFormTextBox();
richTextEditor.RichText = true;
richTextEditor.RichTextMode = SPRichTextMode.FullHtml; // (Can be set as FullHtml, Compatible or HtmlAsXml
The text entered into the control can be get/set in the Text property.
Set the richTextEditor.MultiLine to true if you want to enable multiline editing.
You can control the height and width in the same way as you use the regular TextBox control from the System.Web.UI.WebControls namespace.
References:
http://msdn2.microsoft.com/en-us/library/microsoft.sharepoint.webcontrols.inputformtextbox.aspx
http://msdn2.microsoft.com/en-us/library/microsoft.sharepoint.sprichtextmode.aspx
Friday, January 18, 2008
RichText control in Sharepoint
Subscribe to:
Post Comments (Atom)
1 comment:
Thanks a lot!! That is what I needed
Post a Comment