In asp.net, how do I get a control’s height according to its percentage?
I can get the width property but I set it to 100% and I need the actual pixels
I need it so I can customize my website according to the computer’s resulotion. (It can be any control – panel,div, etc)
Just access the (out of the box) control’s height property in pixels. Calculate the ratio of this width divided by width of its container in the page and express this number as a percentage.
For example:
(myControl.height/myPanel.height)/100 + “%”;
However, this is not the way to design a Web page to play nice in different sized browsers. Depending on what type of control you’re using, this could get real messy and I’m just talking appearance here. Use fixed width for this and your container. Progressively enhance your site with CSS and JS if you need to.
At the risk of getting roasted, I’m going to say this: NEVER used liquid layouts – they change the ratio of the layout and destroy the page composition. Using liquid layouts always ends up with you having to apply code to change the image/height ratio of your images in relation to their container – and this always results in loss of image quality and/or bad page composition.