title: How can I make a Sharepoint textbox (input, type=text) dynamically Multiline?
body: <p>I want a textbox on my Web Part that will grow vertically on demand. That is, it will be one line unless the user enters too much text for that line, at which point it word wraps and grows vertically to accommodate the verbosity of the user.</p>
  
  <p>I am creating my controls/elements dynamically, and I create this element like so:</p>
  
  <pre><code>boxPaymentExplanation = new TextBox()
  {
      CssClass = "dplatypus-webform-field-input"
  };
  boxPaymentExplanation.Width = 660;
  boxPaymentExplanation.Style.Add("display", "inline-block");
  </code></pre>
  
  <p>I tried adding this line, in the hopes of achieving this functionality:</p>
  
  <pre><code>boxPaymentExplanation.Style.Add("TextMode", "MultiLine");
  </code></pre>
  
  <p>...but it makes no apparent change to the textbox's behavior - I can enter text into it "until the bovines come back to the barn" but it simply keeps adding the characters to the end of the textbox on a single row. It never wraps, so it never grows.</p>
  
  <h2>UPDATE</h2>
  
  <p>This is the jQuery that works (derived from the link that Christopher Jennings provided):</p>
  
  <pre><code>$(document).on("keyup", "[id$=explainPaymentTextBox]", function (e) {
      while ($(this).outerHeight() &lt; this.scrollHeight + parseFloat($(this).css("borderTopWidth")) + parseFloat($(this).css("borderBottomWidth"))) {
          $(this).height($(this).height() + 1);
      };
  });
  </code></pre>
  
  <p>...along with this C#:</p>
  
  <pre><code>boxPaymentExplanation = new TextBox()
  {
      CssClass = "dplatypus-webform-field-input",
      ID = "explainPaymentTextBox"
  };
  boxPaymentExplanation.Width = 660;
  boxPaymentExplanation.Style.Add("display", "inline-block");
  boxPaymentExplanation.TextMode = TextBoxMode.MultiLine;
  </code></pre>
  
  <h2>UPDATE 2</h2>
  
  <p>Unfortunately, although the descent-into-the-mælström-esque jQuery above works for dynamically growing the textbox, it doesn't work if the user <em>removes</em> text; I would like it also to shrink when that happens...</p>