Solved

Dynamically size a grid based on availabe screen height

Posted on 2011-02-19
2
420 Views
Last Modified: 2012-05-11
I am using Masterpage and contentpages... on the content pages I have a header and a middle section and I have a grid on the bottom.

I want to size that grid so it takes up the rest of the available space on the screen... in old vb it would be something like Screen.height - grid.top = grid.height.

Thank you!
0
Comment
Question by:md0333
2 Comments
 
LVL 14

Accepted Solution

by:
CtrlAltDl earned 500 total points
Comment Utility
You want to use some JavaScript client-side scripting, so it can be calculated correctly for their particular browser.

In my script below it assumes you have a header div and a footer div.  It subtracts the header and footer from the browsers available view space and resizes your grid (myGrid) to the available space.

<script type="text/javascript">
function resizeContent() {
     //Get/Set your available height
     var availHeight = window.innerHeight || document.documentElement.clientHeight || document.body.clientHeight;
     var footerHeight = document.getElementById("footerDiv").offsetHeight;
     var headerHeight = document.getElementById("headerDiv").offsetHeight;
     
     availHeight = footerHeight - headerHeight - availHeight;
     
     document.getElementById("myGrid").setAttribute("height", availHeight);
</script>

Open in new window

0
 

Author Comment

by:md0333
Comment Utility
Thank you!
0

Featured Post

What Is Threat Intelligence?

Threat intelligence is often discussed, but rarely understood. Starting with a precise definition, along with clear business goals, is essential.

Join & Write a Comment

I recently went through the process of creating a Calendar Control of events with the basis of using a database to keep track of the dates that are selectable, one requirement was to have the selected date pop-up in a simple lightbox.  At first this…
In .NET 2.0, Microsoft introduced the Web Site.  This was the default way to create a web Project in Visual Studio 2005.  In Visual Studio 2008, the Web Application has been restored as the default web Project in Visual Studio/.NET 3.x The Web Si…
Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…
Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.

728 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

Need Help in Real-Time?

Connect with top rated Experts

9 Experts available now in Live!

Get 1:1 Help Now