View Full Version : How to create a textfield and extend it

02-18-2012, 08:37 PM
Hi all,

I'm very new to ASP.NET programming and for a project at school we have to make a products maintenance page and for the description field I was wondering how you make the text field bigger. Not width but height. I tried putting in the height here.

<asp:TextBox ID="txtDescription" CssClass="TextBoxes" style="top: 130px; left: 656px; width: 140px; height: 50px;"

But when I start typing into the description textfield it doesn't start at the top. Does anyone know how to create it so it can start at the top and continue to go down as I reach the end of the width of the textfield and onto the next line of the textfield?

I know how to do this in html using cols: 10px;

I just have no idea how you would do this in asp.net

Help would be great thanks!

02-18-2012, 11:28 PM
you need to change the text box to multi-line... you can do this several ways... there is the properties window, where the textbox is default single line... clicking the dropdown and changing it to multi-line adds this

<asp:TextBox ID="TextBox1" runat="server" TextMode="MultiLine"></asp:TextBox>

my prefered method is to do pretty much everything in the code behind... I just feel it is better practice...

<!-- HTML section -->
<asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>
// code behind
protected void Page_Load(object sender, EventArgs e)
TextBox1.TextMode = TextBoxMode.MultiLine;

essentially doing this makes it so the textbox does not get rendered as an input, but as a textarea