I have a textbox as follows:
<asp:TextBox ID="TextBox1" runat="server" Width="100px" Rows="3" ReadOnly="true"
BorderStyle="None" BorderWidth="0" TextMode="MultiLine" Text='<%# Eval("Notes") %>'
BackColor="#222222" ForeColor="White"></asp:TextBox>
How can I make it so that the vertical scrollbar is not displayed when the textbox is either empty or it doesn’t need to scroll because the text fits in the 3 lines?
You can do this with CSS by specifying
overflow:auto;. You can manually add this attribute to theCssStyleCollectionatTextBox1.Stylein your page’s code-behind, or you can apply aCssClassvalue declaratively and define the css class in an external stylesheet.Here is some documentation on CSS
overflow: http://www.quirksmode.org/css/overflow.htmlHere is some documentation on the
TextBox.Styleproperty: http://msdn.microsoft.com/en-us/library/system.web.ui.webcontrols.webcontrol.style