Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
  1. #1
    Regular Coder
    Join Date
    Oct 2009
    Location
    London, ON
    Posts
    112
    Thanks
    4
    Thanked 0 Times in 0 Posts

    How to create a textfield and extend it

    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.
    Code:
    <asp:TextBox ID="txtDescription" CssClass="TextBoxes" style="top: 130px; left: 656px; width: 140px; height: 50px;" 
                runat="server"></asp:TextBox>
    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!

  • #2
    Senior Coder alykins's Avatar
    Join Date
    Apr 2011
    Posts
    1,742
    Thanks
    41
    Thanked 191 Times in 190 Posts
    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
    Code:
    <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...
    Code:
    <!-- 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

    I code C hash-tag .Net
    Reference: W3C W3CWiki .Net Lib
    Validate: html CSS
    Debug: Chrome FireFox IE


  •  

    Tags for this Thread

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •