Telerik
Home / Support / Knowledge Base / RadControls for ASP.NET and ASP.NET AJAX / PanelBar / Making RadPanelBar occupy 100% of browser window's height

Making RadPanelBar occupy 100% of browser window's height

Article Info

Rating: 4


Article information

Article relates to

RadPanelBar v3.x "classic"
RadPanelBar for ASP.NET AJAX
(Telerik.Web.UI 2008.1.x)

Created by

Paul, Telerik

Last modified by

Veskoni, Telerik

HOW-TO
Make RadPanelBar occupy 100% of browser window's height.



SOLUTION
By design, in its Height property RadPanelBar accepts a pixel value only. This makes it hard to extend the panelbar to occupy 100% of the height of the browser. Here are the steps to accomplish that:

1. Set an unusually large number in the Height property of your RadPanelBar - i.e. Height="3000px";
2. Add this script in your aspx page:

<script type="text/javascript"
function pageLoad() 
    resizePanelBar(); 
 
function resizePanelBar() 
 { 
  var thePanelbar = document.getElementById("RadPanelBar1"); 
  var intCompensate = 0; 
  var documentObj = document.documentElement; 
  if (window.opera || (document.all && !(document.compatMode && document.compatMode == "CSS1Compat"))) 
  { 
   documentObj = document.body; 
  } 
  thePanelbar.style.height = (parseInt(documentObj.clientHeight) - intCompensate) + "px"
  if (!document.readyState) 
  { 
   document.readyState = "complete"
  } 
 
window.onresize = resizePanelBar; 
</script> 

3. Add the following style in the body tag:

<body style="margin:0px"

This will guarantee that even after you resize the browser the panelbar will occupy the full visible height of the window.

SOLUTION (v.3.x)
By design, in its Height property RadPanelBar accepts a pixel value only . This makes it hard to extend the panelbar to occupy 100% of the height of the browser, especially if you have set the FullExpandedPanels and SingleExpandedPanel properties to true.
However it is possible to make the panelbar occupy the 100% of the visible height of the browser window. Here are the steps to accomplish that:

  1. Set an unusually large number in the Height property of your RadPanelBar - i.e. Height="3000px";
  2. Set SingleExpandedPanel="True" and FullExpandedPanels="True";
  3. Create the following JavaScript function:
  4. <script type="text/javascript"
    function OnPanelResize() 
     { 
      var thePanelbar = document.getElementById("RadPanelBar1"); 
      var intCompensate = 0; 
      var documentObj = document.documentElement; 
      if (window.opera || (document.all && !(document.compatMode && document.compatMode == "CSS1Compat"))) 
      { 
       documentObj = document.body; 
      } 
      thePanelbar.style.height = (parseInt(documentObj.clientHeight) - intCompensate) + "px"
      if (!document.readyState) 
      { 
       document.readyState = "complete"
      } 
      RadPanelBar1.Height = parseInt(documentObj.clientHeight) - intCompensate; 
      RadPanelBar1.InitFullExpandOpera(); 
     } 
     window.onload = OnPanelResize; 
     window.onresize = OnPanelResize; 
    </script> 

  5. Here RadPanelBar1 is the ID of your panelbar. Replace it as needed. It is up to you to choose the value of the intCompensate variable. In an empty webform with just the panelbar on it, 0 pixels make the top and bottom margins between the Panelbar and the window borders quite similar.
     
  6. Add the following attributes to the <body> tag of the webform:

    <body style="margin:0px"

This will guarantee that even after you resize the browser the panelbar will occupy the full visible height of the window.

Comments

  • Renan , Jun 22, 2008

    Just what I'm looking for, thanks guys!

  • andrew rekvils , Dec 4, 2008

    This does not seem to work the very first time RadPanelBar is displayed. If I enject alert(thePanelbar.style.height) after it is set, it shows new height as it should be but still displays panelbar with original size. This is unless I make the very first resize. Any ideas?

  • Telerik Admin , Jan 14, 2009

    Please open a new support ticket and send us a sample project demonstrating the problem.

If you'd like to comment on this KB article, please, send us a Support Ticket.
Thank you!

Please Sign In to rate this article.

Powered by Sitefinity ASP.NET CMS

Contact Us | Site Feedback | Terms of Use | Privacy Policy
Copyright © 2002-2010 Telerik. All rights reserved.