newbie: problem with Panel Height!

Discussion in 'ASP .Net' started by Jeff, Jul 13, 2006.

  1. Jeff

    Jeff Guest

    hey 2.0

    I have a Panel on my webpage. Within this Panel is a Label control which
    displays text over several rows...
    I just tested this and when running the webpage with a lot of data in the
    label control -> The label control writes pass the Panel control.

    I want the Panel to extend it's height automically if the height of it's
    content is higher than the Panel orginally can display.

    Here are some of my settigns for the Panel control;
    ID="Panel1" runat="server" Height="100%"
    I also tryed using Height="500px"; without any luck

    Any suggestions to this?
    Jeff, Jul 13, 2006
    1. Advertisements

  2. Jeff

    Guest Guest

    Hi Jeff.

    The panel control renders as a div element on the HTML page. Consequently,
    assigning the height attribute isn't going to impact the display.

    For better control, you might want to nest the label control inside a table.
    You can use the table to better manage the presentation. You could also
    attach a CSS class to the panel -- in fact, that's probably the cleanest

    When I first got started using ASP.NET, I used the label control everywhere.
    As you get more comfortable with the built-in controls, you'll likely want to
    gravitate toward a GridView for presentation of database fields or one of the
    other controls that is better suited for this amount of data.

    Good luck.

    Guest, Jul 13, 2006
    1. Advertisements

  3. Jeff

    Guest Guest

    I agree and have one thing to add for newbies.

    Often people want to use a panel becuase its border defaults to a nice thin
    border while a table is not as slick at default.
    However the following makes a nice thin border
    <table width="100%" style="border: 1px solid; border-color:DarkBlue"
    border="0" cellpadding="0" cellspacing="0" >
    Guest, Jul 13, 2006
  4. Jeff

    Jeff Guest

    Thanks, I'm trying your CSS suggestion:

    However I got some problems getting this to work, "height:100%" isn't
    working. The text still writes pass the Panel control.

    Here are more info
    (I use green and red colors to test if the page actually reads the CSS
    styles, and Yes the green and red color works. But the height have no

    Part of MasterPage.master
    <asp:panel ID="Panel1" runat="server" Style="z-index: 100; left: 165px;
    position: absolute; top: 107px" Width="602px" CssClass="profile_info">
    <asp:ContentPlaceHolder ID="content" runat="server">

    Part of Default.aspx:
    <asp:Label ID="lblInfo" runat="server" Height="14px" Style="z-index: 107;
    left: 5px;
    position: absolute; top: 232px" Width="589px"></asp:Label>

    The ContentPlaceHolder and the Panel is placed on a master page. And
    Default.aspx are using this master page. The Label control is on the
    Default.aspx file

    I would prefer to use CSS instead of table.....

    Any suggestions?

    Jeff, Jul 14, 2006
  5. Jeff

    Guest Guest

    If i understand what you want correctly if you want a panel to grow and
    shrink given the amount of information you have you are better off not using
    a panel at all but rather a table.
    Second thing to keep in the back of your mind most controls have issues with
    Height=100%. The reason for this is becuase in theory a web browser has an
    infinite height becuase it has a scroll bar so the controls basically wonder
    "how far is 100% anyway?"

    In short, for autogrow/shrink solutions the best solutions are div's and
    Now if you need server side control over your tables you can do that however
    that is a different subject.
    Guest, Jul 14, 2006
  6. Jeff


    Aug 3, 2011
    Likes Received:
    i use gridview in a panel. what i do is by setting the panel height equal to gridview height. it makes the panel flexible to follow the height of the gridview.

    hermanjul, Aug 3, 2011
    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.