Rather than centering the image on the entire page, I use the following setup to ensure that the loading image is visible on the page if the container being updated is visible. Depending on the position of the area being updated, the image will try to move as close to the vertical center of the page as possible so that the loading image is nearly always visible. This works with '09 Q1 using skins as well as older versions which have custom content. Depending on the content of your LoadingPanel, you may need to adjust the amount of padding added.
The .aspx file:
The .js file:
Note that this is nearly identical to the centering method provided by Telerik in the help file except that this uses padding and relative positioning. I find this more useful in settings where there are multiple controls that will be updated but the whole page doesn't need to be covered by a blanket LoadingPanel. Hope this was helpful!
The .aspx file:
<telerik:RadAjaxManager ID="RadAjaxManager1" runat="server" DefaultLoadingPanelID="RadAjaxLoadingPanel1"> |
<ClientEvents OnRequestStart="ajaxRequestStart();"/> |
... |
</telerik:RadAjaxManager> |
<telerik:RadAjaxLoadingPanel ID="RadAjaxLoadingPanel1" runat="server" BackgroundPosition="Top" Skin="WebBlue"/> |
<telerik:RadScriptBlock ID="RadScriptBlock1" runat="server"> |
<script type="text/javascript"> |
function ajaxRequestStart() |
{ |
centerUpdatePanel($get('<%= RadAjaxLoadingPanel1.ClientID %>')); |
} |
</script> |
</telerik:RadScriptBlock> |
The .js file:
function centerElementWithPadding(element) |
{ |
try |
{ |
var scrollTop = document.body.scrollTop; |
var viewPortHeight = document.body.clientHeight; |
if (document.compatMode == "CSS1Compat") |
{ |
viewPortHeight = document.documentElement.clientHeight; |
scrollTop = document.documentElement.scrollTop; |
} |
var topOffset = Math.ceil(viewPortHeight / 2 - element.offsetHeight / 2); |
var top = scrollTop + topOffset - 40 - 100; // Adjust the padding here if necessary |
element.style.paddingTop = top + "px"; |
} |
catch (err) |
{ |
} |
} |
Note that this is nearly identical to the centering method provided by Telerik in the help file except that this uses padding and relative positioning. I find this more useful in settings where there are multiple controls that will be updated but the whole page doesn't need to be covered by a blanket LoadingPanel. Hope this was helpful!