Solved

Calculate height/width for a control

Posted on 2007-11-24
3
470 Views
Last Modified: 2012-06-21
Hi,

I have a control on my aspx page, it has a Height and Width property that I want to set on Page_Load. The height and width should correspond to the browser windows size (depending on users resolution) and therefore the control should fill the entire browser window (without the scroll bars appearing when the browser is maximised). How can I calculate the height and width for this control? There should be no whitespace on the page, just the whole control filling the page.

Thank you very much for any help.
0
Comment
Question by:Programmer_to_be
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
3 Comments
 
LVL 29

Accepted Solution

by:
Göran Andersson earned 125 total points
ID: 20342654
The server doesn't know the size of the browser window. If you want that information available to the server, you have to use a Javascript in a page that sends that information back to the server in a request, so that you can use it when you create the next page. Also, this only gives information about the size at the moment when the request is sent, the user can resize the window at any time.

I suggest that you use css to specify the size of the control, so that it will resize automatically according to the window size. Something like:

html, body { width: 100%; height: 100%; overflow: hidden; }
body { margin: 0; padding: 0; }
.TheControl { width: 100%; height: 100%; }

The width and height on the html and body tag is needed to make them fill the browser window. The overflow makes sure that there are no scroll bars.

Specifying margin and padding makes sure that there is no space between the control and the window edges.

You use the TheControl class on your control by specifying it as class name. For an html control you use class="TheControl", for a web control you use CssClass="TheControl".

Specifying the size of the control that way makes it the size of it's parent control. If you have a form around the control you may also need:

form { margin: 0; width: 100%; height: 100%; }
0
 

Author Closing Comment

by:Programmer_to_be
ID: 31410763
A very well explained solution.
0
 

Author Comment

by:Programmer_to_be
ID: 20346641
Thank you GreenGhost for taking the time out to explain the solution. It worked a charm!
0

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

One of the pain points with developing AJAX, JavaScript, JQuery, and other client-side behaviors is that JavaScript doesn’t allow for cross domain request for pulling content. For example, JavaScript code on www.johnchapman.name could not pull conte…
International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
A short tutorial showing how to set up an email signature in Outlook on the Web (previously known as OWA). For free email signatures designs, visit https://www.mail-signatures.com/articles/signature-templates/?sts=6651 If you want to manage em…
This video shows how to use Hyena, from SystemTools Software, to update 100 user accounts from an external text file. View in 1080p for best video quality.
Suggested Courses

752 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question