title: Automatic TextBox Width
body: <p>There is a <a href="https://stackoverflow.com/questions/7477/autosizing-textarea-using-prototype">similar thread about this</a>.  But I want to have a multiline TextBox with automatic width (<strong>fit width to the larger row</strong>).</p>
  
  <p>With this code I can have a multiline TextBox (automatic height) </p>
  
  <pre><code>     &lt;div style="float:left; white-space:nowrap "&gt;
          &lt;asp:TextBox style="display:inline; overflow:hidden"  
                       ID="txt1" 
                       runat="server" 
                       Wrap="false" 
                       ReadOnly="true" 
                       TextMode="MultiLine" 
                       BorderStyle="none" 
                       BorderWidth="0"&gt;
          &lt;/asp:TextBox&gt;
      &lt;/div&gt;
      &lt;div style="float:left"&gt;
          &lt;asp:TextBox ID="txt2" runat="server" Text="Example textbox"&gt;&lt;/asp:TextBox&gt;
      &lt;/div&gt;
  </code></pre>
  
  <p>Code behind:</p>
  
  <pre><code>txt1.Rows= text.Split("|").Length ' Sets number of rows but with low performance
  txt1.Text = text.Replace("|", Environment.NewLine)
  </code></pre>
  
  <p>Once again, thanks for your help.</p>