473,503 Members | 1,136 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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

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

Oct 25 '06 #1
1 1881
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
Oct 25 '06 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
372
by: Barrett | last post by:
Hello, basically I want to be able to determine the height of a panel at runtime on a webform. The only value I can squeeze out of the control properties is the height that is set at design time....
1
1260
by: Bob Rosen | last post by:
I would like to place some button controls on a web page underneath a DataGrid control. Since the height of the DataGrid depends on the number of rows displayed, which is determined by user...
5
1558
by: Steve | last post by:
Visual Studio 2003 .Net / C# I have a 2 page Tab Control for users to add a Job in my application. The first page is for them to choose which type of Job they would like. The type of Job...
11
4475
by: Georges Heinesch | last post by:
Hi. I have several controls at the same position. The are made visible one after the other using the .Visible property. While in the design view, I see only the upper control. How can I make...
8
4297
by: Donald Xie | last post by:
Hi, I noticed an interesting effect when working with controls that are dynamically loaded. For instance, on a web form with a PlaceHolder control named ImageHolder, I dynamically add an image...
2
1143
by: Eric | last post by:
I am in need of some advice on how to do the following: Have some type of container on form that would fill the visible area on screen (assuming the browser was maximized). I would like to...
16
1192
by: Tym | last post by:
I have a piece of code thus: For iLOOP = 0 To iNoDays - 1 For jLOOP = 0 To iMaxPeriods - 1 iX = 10 + (iLOOP * (dCellWidth + 10)) iY = 10 + (jLOOP * (dCellHeight + 10)) + Me.Size.Height / 4 If...
2
13981
by: JohnR | last post by:
Let's say I have an MDI parent form with a textbox. If I create an MDI child form and, at runtime, move the MDI child window over the textbox on the MDI parent, the textbox appears in front of the...
4
1959
by: rushikesh.joshi | last post by:
Hi All, I have created my own WebControl and want to add it in my aspx page at runtime. it's compiling perfectly, but when i m going to execute, it gives me error of "Object reference not set...
0
7203
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
7339
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
6995
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
1
5017
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
4678
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3168
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
3157
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
738
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
389
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.