Karine Bosch’s Blog

On SharePoint

InputFormTextBox Control


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:

inputformtextbox

<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=12.0.0.0, 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.

20 Comments »

  1. Hi Karine,

    How can I add spuc:InputFormTextBox on my custom ascx???

    Later, I would place my custom ascx on webpart.

    Thanks & Regards
    Khushi

    Comment by Khushi | September 18, 2009 | Reply

  2. Hi,

    I have added InputFormTextBox control in one .ascx but on postback data from InputFormTextBox get disappear.
    I mean control not render with it’s content. Do you have any idea

    Thanks & Regards,
    Sarika

    Comment by Sarika | January 17, 2010 | Reply

  3. Can you post your code?

    Comment by Karine Bosch | January 18, 2010 | Reply

    • I have tried this in the past and it did notwork. Also the RichText Icons do not show.

      Comment by BigRay | December 14, 2010 | Reply

      • I have tried placing same spuc user control for multiline, in my visual web part but it dint render as show in the above images.And i also tried Sharepoint:InputFormField ,but it didnt work,

        Comment by swetha | July 19, 2017

  4. Added InputFormTextBox control in .ascx as

    Then on same .ascx I have one fileupload control… Which upload the attachment. when upload any attachment, page get postback. Same time data from InputFormText control became empty.

    if I check inFormTxtBody.text it gives me the data which I had added. but control not showing the data.
    I notice one thing Control is render as . data is not in TextArea.

    Comment by sarika | January 18, 2010 | Reply

  5. Comment by sarika | January 18, 2010 | Reply

  6. Hi,

    I have InputFormTextBox used in some custom pages in SharePoint 2007 applications. Now I am migrating these pages to SharePoint 2010. But the toolbar of InputFormTextBox is completely distorted. It has all “B” “B” “B” in place of images on buttons on toolbar. Any idea if InputFormTextBox is compatible with SharePoint 2010? I am using some master pages from SharePoint 2007. Would that cause the issue?

    Regards,
    Rahul Khedekar.

    Comment by Rahul | March 3, 2010 | Reply

    • i am also facing same problem

      Comment by Yogesh | April 21, 2010 | Reply

  7. Hi Rahul,
    I just started to migrate the code from this SharePoint Demo project and I have no problem with the InputFormTextBox using this markup:
    spuc:InputFormTextBox runat=”server” ID=”InputFormTextBox3″ TextMode=”MultiLine” Columns=”100″ Rows=”12″
    RichText=”true” RichTextMode=”FullHtml” AllowHyperlink=”true” Direction=”NotSet”
    (the XML tags are left out, otherwise it wouldn’t render)
    What’s the markup you use?
    Karine

    Comment by Karine Bosch | April 21, 2010 | Reply

    • Hi Karine,

      I am also facing the same problem using the custom web part.

      _txt.TextMode = TextBoxMode.MultiLine;
      _txt.Rows = 10;_txt.RichText = true;
      _txt.RichTextMode = SPRichTextMode.FullHtml;

      Comment by Yogesh | April 21, 2010 | Reply

  8. I use it from within a custom application page. Perhaps it has something to do with the width of the webpart. I’ll try it out during the weekend and post my findings.
    Karine

    Comment by Karine Bosch | April 21, 2010 | Reply

  9. Hi, I am using a SharePoint’s text box control in one of my task edit forms for workflow. My problem is the lack of flexibility when it comes to culture specific characters. I would like to use Cyrilic letters, but it seems that this and other SharePoint controls use ASCII instead of Unicode.

    Am I missing something here? Any reply would be appriciated.

    Thanks in advance

    Comment by Zarko | May 5, 2010 | Reply

  10. Hi Karine,

    I have created a webpart using inputformtextbox. But when I click the image button, I doesn’t show the browse option for the image.

    Any property setting is there?

    Thanks in advance,

    Comment by Selvavelan | October 11, 2010 | Reply

  11. Thanks a lot .

    Comment by Manoj padhi | February 16, 2012 | Reply

  12. Hi Karine,
    How can we add Sharepoint 2010’s Enhanced Rich Text Box to my visual web part? Thanks in advance.

    Comment by Mohan Udupa | April 30, 2012 | Reply

  13. As the visual web part also contains an .ascx control, you can add the InputTextBox control the same way as explained in this post, and set the properties correctly to have it behave as a Richt text box.

    Comment by Karine Bosch | May 1, 2012 | Reply

  14. Hi Karine,

    I have got an issue in SharePoint 2010 site. This site has been upgraded from SharePoint 2007 and we did’t do visual upgrade on this site. The rich text box behaving quite weird. All the icons at the top bar repeating multiple times.
    Any idea how to fix it.
    Thanks

    Comment by Faisal | January 31, 2013 | Reply

    • Hi Faisal,
      I’m afraid I can’t help hou on this: I haven’t tested this out in a scenario where no visual upgrade was performed. I advise you tyo place your question on the SharePoint forum, there you will have more chance for an answer.
      Kind regards,
      Karine

      Comment by Karine Bosch | February 1, 2013 | Reply

  15. Hi Faisal i having the same problem.All the icons at the top bar repeating multiple times.If u solved the issue then let me know how to do it.

    Comment by kapil | May 23, 2013 | Reply


Leave a comment