|
Article relates to
|
RadWindow for ASP.NET AJAX
|
|
Created by
|
Marin Bratanov, Telerik
|
|
Created on
|
5th of January 2012
|
HOW-TO:
Set the size of a
RadWindow in percent.
DESCRIPTION:
The
RadWindow supports its size in pixels only, as does any other window, e.g. in the operating system - changing the screen resolution or adding other elements in the viewport do not change the dimensions of the already existing windows. Therefore the
RadWindow has the same behavior.
SOLUTION:
You can use a combination of the RadWIndow's
client-side API and jQuery to calculate the needed dimensions in pixels from the available viewport and set them to the RadWindow. You should also handle the window.resize event in order to recalculate the size when the browser size changes:
get the viewport size:
change the RadWindow size where value is the size in percent you need:
You can then center the RadWindow:
This can be encapsulated in a function that will be called after the browser is resized. Note how the timeout is used to ensure that the handler is called only once, because older browsers throw the window.resize event numerous times which may result in poor performance without such an insurance:
Where TO is a global JavaScript variable that holds the timeout.
A simple page that shows the approach in action is attached to this post as well. Inside there are comments that explain in greater detail what the code does. This can be used as base for further extending this scenario, but you should keep in mind that it has its limitations - e.g. it cannot work for a restriction zone as you cannot handle the zone's size change, there is simply no such event.
Please
Sign In
to rate this article.