Getting an asp.net TextBox to fill a screen and adjust heightdynamically

Discussion in 'ASP .Net' started by Terry, Feb 20, 2008.

  1. Terry

    Terry Guest

    I am trying to figure out if there is a way to get a regular asp.net
    TextBox to fill the screen, both height and width. When I drop a
    TextBox onto a blank asp.net page and set the height="100%",
    width="100", and the TextMode="MultiLine", the TextBox will fill the
    width of the page, and will adjust the width dynamically as the page
    changes size, but the height of the textbox is not full screen as I
    would like. It remains at 2 lines high.

    Is there a way to get the height of a textbox to fill the screen, and
    adjust its size automatically when the screen size changes? Thanks.
     
    Terry, Feb 20, 2008
    #1
    1. Advertisements

  2. Terry

    Scott M. Guest

    Textbox height may only be adjusted on a row of input basis by setting the
    Textmode property to Multi-line and then the Rows property to the desired
    row amount. You cannot set a textbox's height in pixels or percent, as you
    can do with other controls.
     
    Scott M., Feb 20, 2008
    #2
    1. Advertisements

  3. Terry

    Terry Guest

    So does that mean it is not possible to set the TextBox height so that
    it will be full screen, and automatically adjust when the page size is
    changed?

    Ultimately what I'm trying to do is create a page very similar to an e-
    mail inbox page, with a grid on the top half of the screen, a splitter
    bar, and a TextBox at the bottom that always fills the bottom half of
    the page, even when the splitter bar is adjusted. I was hoping I
    could do this with a TextBox on the bottom. Any suggestions?
     
    Terry, Feb 20, 2008
    #3
  4. Terry

    bruce barker Guest

    trival:


    <%@ Page Language="C#" AutoEventWireup="true" CodeFile="FullTextBox.aspx.cs"
    Inherits="FullTextBox" %>
    <html>
    <body style="margin:2px;border:0px;padding:0px;"
    onresize="doResize();"
    onload="doResize();"<script>
    function doResize(){
    var txt1 = document.getElementById('<%=txt1.ClientID %>');
    txt1.style.height=(document.body.clientHeight-6)+'px';
    }
    </script>
    <form id="form1" runat="server">
    <asp:textbox
    id="txt1"
    style="width:100%;margin:0px;border:1px black solid;padding:0px;"
    runat="server"
    TextMode="MultiLine"
    />
    </form>
    </body>
    </html>


    -- bruce (sqlwork.com)
     
    bruce barker, Feb 20, 2008
    #4
  5. Terry

    Terry Guest

    Thanks Bruce! That that worked exactly as I had hoped.

    I did find that the "onresize" event in the body element is not valid
    for XHTML Transitional markup. I took out the DOCTYPE reference to
    test your code, and it worked. I'll probably have to find a work-
    around for the onresize event if I want my web page to enforce XHTML
    Transitional.

    Thanks again.
     
    Terry, Feb 20, 2008
    #5
  6. Terry

    bruce barker Guest

    xhtml has no replacement (it just depicated, not removed), but its a valid
    event for html 4.0/ 5.0/ xhtml2 (undepicated if htmlelement).


    -- bruce (sqlwork.com)
     
    bruce barker, Feb 20, 2008
    #6
  7. Terry

    Terry Guest

    Good additional info. Thanks Bruce!
     
    Terry, Feb 21, 2008
    #7
  8. Terry

    s14raj

    Joined:
    Nov 16, 2011
    Messages:
    1
    Likes Received:
    0
    TextBox b=new TextBox ();
    b.TextMode=TextBoxMode.MultiLine; // for Textmode
    b.Width=200; //for Width
    b.Height = 100; //for Height



     
    s14raj, Nov 16, 2011
    #8
    1. Advertisements

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.