When developing application pages or web parts, you can use this control to place a textbox on the user interface. You can set properties so that the text box renders as single line, multi line or password. You can also choose for a normal text box or a rich text box.
The figure contains an example of a single-line InputFormTextBox and an example of a muti-line rich text box:
<spuc:InputFormTextBox runat="server" ID="InputFormTextBox3" Width="60%" />
Add the required directive at the top of the page:
<%@ Register TagPrefix="spuc" Namespace="Microsoft.SharePoint.WebControls" Assembly="Microsoft.SharePoint, Version=22.214.171.124, Culture=neutral, PublicKeyToken=71e9bce111e9429c" %>
You can also create this type of control completely in code:
InputFormTextBox textbox = new InputFormTextBox(); textbox.ID = "inputFormTextBox1"; textbox.TextMode = TextBoxMode.MultiLine; textbox.Rows = 5; textbox.Columns = 75;
There are a number of properties/attributes that you can set:
- ID: control id.
- Text: the string within the control.
- ErrorMessage: you can define a custom error message that will be displayed when an error occurs.
- ErrorMessageLabelControl: you can specify a control id of a control on the page in which the error message will be rendered.
- TextMode: accepts a value of type TextBoxMode. Possible values are MultiLine, SingleLine and Password. The default is SingleLine.
- Columns: indicates the width of the text box.
- Rows: indicates the number of rows that will be displayed. This is only applied if the TextMode property is set to MultiLine.
- RichText: indicates if a normal text box or a rich text box will be displayed. The default value is false. The text box will only be rendered as a rich text box if the TextMode property is set to MultiLine.
- RichTextBoxMode: accepts a value of type SPRichTextMode. Possible values are Compatible, FullHtml and HtmlAsXml. The default value is Compatible. this property only applies if the RichText property is set to true.
- AllowHyperlink: this property only applies if the RichtText property is set to true. The necessary controls to insert hyperlinks and images will be added to the tools pane.
- Direction: This orders the controls in the tools pane from left to right or from right to left. The value is of type ContentDirection having values NotSet, LeftToRight, RightToLeft. The default value is NotSet. This property only applies if the RichText property is set to true.
When opting for rich text mode, there can be problems with the width of the control. If you want to render the control over the full width of the page, you can read this post from Dario Martirani.