有一個similar thread about this。但我想擁有自動寬度的多行文本框(適合寬度較大的行)。自動文本框寬度
有了這個代碼,我可以有一個多行TextBox(自動高度)
<div style="float:left; white-space:nowrap ">
<asp:TextBox style="display:inline; overflow:hidden"
ID="txt1"
runat="server"
Wrap="false"
ReadOnly="true"
TextMode="MultiLine"
BorderStyle="none"
BorderWidth="0">
</asp:TextBox>
</div>
<div style="float:left">
<asp:TextBox ID="txt2" runat="server" Text="Example textbox"></asp:TextBox>
</div>
後面的代碼:
txt1.Rows= text.Split("|").Length ' Sets number of rows but with low performance
txt1.Text = text.Replace("|", Environment.NewLine)
再次感謝您的幫助。
偉大的提示nunespascal,但我不能使用jQuery,謝謝。 – Coyolero 2012-07-11 18:55:07