RadAjax for ASP.NET

Show and hide loading panel explicitly Send comments on this topic.
See Also
AJAX Loading Panel > AJAX Loading Panel How-To > Show and hide loading panel explicitly

Glossary Item Box

To display the loading panel over an element, just call the Show method client-side. This allows you to update controls according to some condition (using the ResolveUpdatedControls event) and display a loading panel over the control that will be updated (Show the panel in OnRequestStart, hide it in OnResponseEnd):

JavaScript Copy Code
  <script type="text/javascript">
    var currentLoadingPanel = null;
    var currentUpdatedControl = null;

    function AjaxRequestStart(sender, args)
    {
        //the RadMenuItem-originated postback will setup the EventArgument with something like RadMenu1$m1
        var menuItemIndex = args.EventArgument.match(/.*?\$m(\d+)/)[1];
        currentLoadingPanel = RadAjaxNamespace.LoadingPanels["<%= AjaxLoadingPanel1.ClientID %>"];

        //find out what we'll be updating
        if (parseInt(menuItemIndex) == 0)
        {
            currentUpdatedControl = "<%=Panel1.ClientID %>";
        }
        else
        {
            currentUpdatedControl = "<%=Panel2.ClientID %>";
        }

        //show the loading panel over the updated control
        currentLoadingPanel.Show(currentUpdatedControl);
    }

    function AjaxResponseEnd()
    {
        //hide the loading panel and clean up the global variables
        if (currentLoadingPanel != null)
            currentLoadingPanel.Hide(currentUpdatedControl);

        currentUpdatedControl = null;
        currentLoadingPanel = null;
    }
    </script>
 

 When you use this approach for RadControls, you need to invoke the currentLoadingPanel.Hide() method with a slight change due to the rendering of the RadControls. The code that shows the loading panels tries to append "_wrapper" at the end of the updated controls, because all of the RadControls' html wrapper elements end in this suffix. However, the code for hiding the loading panel will not look for the wrapper suffix, which will cause a javascript error. To use the above script for RadControls please apply the following change to the Hide() method:

currentLoadingPanel.Hide(currentUpdatedControl+"_wrapper"); 

See Also