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

W

Wotney

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
 
F

Flinky Wisty Pomm

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.
 

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. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,054
Latest member
TrimKetoBoost

Latest Threads

Top