measuring web controls height at runtime (or converting .height % to px)

Discussion in 'ASP .Net' started by Wotney, Oct 25, 2006.

  1. Wotney

    Wotney Guest

    Hoping someone out there can help...

    I have an UpdatePanel that uses Atlas/Ajax to update it's contents
    without having to postback the entire page. (pnlUpdate)

    Within pnlUpdate I have a normal panel holding a tree-view control.
    (pnlTreeView)

    All the controls on my page are dynamic in size. Eg. Height="80%",
    Width = "85%".

    As expected... Upon using the tree-view control... when exposing the
    next level of nodes the control gains in height so it can display the
    new child nodes.


    This is where the problem lies.

    When pnlTreeView increases in size, all the parent controls (the panels
    it sits in) also gain in size. (looks stupid)

    But !

    If I set the pnlTreeView Height to a px value rather than a %... when
    the child nodes are exposed, the control remains the same size and
    displays scrollbars (perfect!)

    Except now it's a fixed size in px, I can't make the treeview expand
    and contract depending on the size of the browser window like all the
    other controls do. (rubbish!)...


    ....So, to get round this I thought I could just set the height of
    pnlTreeView dynamically at run time on the 'Node_Expanded' Sub
    based on the height of it's parent control.


    I set pnlUpdate to Height=85%

    All I want to do is (within code at runtime) is say

    pnlTreeView.Height = pnlUpdate.Height

    (Seems easy enough... BUT)

    Using the above code sets pnlTreeView.height to 85%

    pnlTreeView must have it's height set in pixels, not as a percentage.

    HELP ?
    PLEASE !!

    Cheers guys & gals,

    Scott
    Wotney, Oct 25, 2006
    #1
    1. Advertising

  2. Set it via Javascript.

    Leave the percentage-based height in place. On page load, read the
    current height of the control in pixels, you can now set the height
    property of the panel to a pixel height, and you're done.

    To get the current height of an element, you have to mutter different
    incantations for different browsers. IIRC prototype.js has a couple of
    functions designed for this purpose, it might be worth a look through
    their source to get the technique.


    Wotney wrote:

    > Hoping someone out there can help...
    >
    > I have an UpdatePanel that uses Atlas/Ajax to update it's contents
    > without having to postback the entire page. (pnlUpdate)
    >
    > Within pnlUpdate I have a normal panel holding a tree-view control.
    > (pnlTreeView)
    >
    > All the controls on my page are dynamic in size. Eg. Height="80%",
    > Width = "85%".
    >
    > As expected... Upon using the tree-view control... when exposing the
    > next level of nodes the control gains in height so it can display the
    > new child nodes.
    >
    >
    > This is where the problem lies.
    >
    > When pnlTreeView increases in size, all the parent controls (the panels
    > it sits in) also gain in size. (looks stupid)
    >
    > But !
    >
    > If I set the pnlTreeView Height to a px value rather than a %... when
    > the child nodes are exposed, the control remains the same size and
    > displays scrollbars (perfect!)
    >
    > Except now it's a fixed size in px, I can't make the treeview expand
    > and contract depending on the size of the browser window like all the
    > other controls do. (rubbish!)...
    >
    >
    > ...So, to get round this I thought I could just set the height of
    > pnlTreeView dynamically at run time on the 'Node_Expanded' Sub
    > based on the height of it's parent control.
    >
    >
    > I set pnlUpdate to Height=85%
    >
    > All I want to do is (within code at runtime) is say
    >
    > pnlTreeView.Height = pnlUpdate.Height
    >
    > (Seems easy enough... BUT)
    >
    > Using the above code sets pnlTreeView.height to 85%
    >
    > pnlTreeView must have it's height set in pixels, not as a percentage.
    >
    > HELP ?
    > PLEASE !!
    >
    > Cheers guys & gals,
    >
    > Scott
    Flinky Wisty Pomm, Oct 25, 2006
    #2
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Carlo Filippini

    Measuring performance of Net::FTP

    Carlo Filippini, Sep 9, 2003, in forum: Perl
    Replies:
    1
    Views:
    1,161
    Philip
    Sep 9, 2003
  2. Guadala Harry

    Measuring Memory Useage

    Guadala Harry, Oct 25, 2004, in forum: ASP .Net
    Replies:
    2
    Views:
    435
    bruce barker
    Oct 25, 2004
  3. Bill Cohagan

    Measuring serialized session "size"

    Bill Cohagan, Nov 24, 2004, in forum: ASP .Net
    Replies:
    1
    Views:
    622
    bruce barker
    Nov 25, 2004
  4. duane
    Replies:
    2
    Views:
    113
    duane
    Sep 13, 2003
  5. Gingko
    Replies:
    0
    Views:
    92
    Gingko
    Feb 1, 2004
Loading...

Share This Page