SharePoint Pals
 | Sign In
How to Make a Feel that the Page Loads Asynchronous in SharePoint 2013
by Sathish Nadarajan 28 Oct 2014
SharePoint MVP
Today  :   5     Total  :    8878

I had an Application page which will open as a Modal Dialog, comprises 2 List boxes, so that the user can toggle the Items from Source to Target and vice versa.

The screen will looks like below.


The entire screen will looks like


If the content on the List box becomes huge, then the page itself, freezes while loading. i.e., the User will see a blank page until all the List Items are rendered on the List Box. This, we can see, if there are around 1000, 2000 items on the List box. To give a better user experience, we thought of giving an Asynchronous feel. Not exactly the Asynchronous Loading. But, a feel that the page loads asynchronously. To accomplish this,

The overall approach followed are as follows.

1. Create 2 divs

2. One having a text like “Loading…”

3. The second one is the actual content div.

4. Keep a hidden button.

5. On the Page_Load, don’t write anything.

6. On the Click event of the hidden button, load the List boxes.

7. On the Click event from the document.ready event.

8. Hence, when the page loads, no load is given to the system. Hence, the page loads with the Loading DIV Tag.

9. And once the page loads, then the Click event gets triggered. Then the actual loading happens. Till the time, the User will be seeing a “Loading…” Message.


Now, let us see the HTML code for this.

 <div class="loading">Loading...</div>
     <div class=" content invisible " style="padding-top: 10px; width: 610px;">
             <legend>Add Pages</legend>
             <table style="width: 600px; margin-top: 20px;">
                     <td colspan="2">
                         <div class="selectDeptBox">
                             <div class="deptSelHeader padding17">Source</div>
                             <asp:ListBox ID="lstSource" runat="server" CssClass="itemYScroll" SelectionMode="Multiple" Height="220px"></asp:ListBox>
                         <div class="selectDeptBut">
                             <asp:Button ID="btnMoveRight" Font-Bold="true" runat="server" Text=">>" OnClick="btnMoveRight_Click" />
                             <div class="clearboth" style="padding-top: 10px"></div>
                             <asp:Button ID="btnMoveLeft" Font-Bold="true" runat="server" Text="<<" OnClick="btnMoveLeft_Click" />
                             <div class="clearboth" style="padding-top: 10px"></div>
                         <div class="selectDeptBox">
                             <div class="deptSelHeader padding17">Target</div>
                             <asp:ListBox ID="lstTarget" runat="server" CssClass="itemYScroll" SelectionMode="Multiple" Height="220px"></asp:ListBox>
             <br />
             <div style="width: 100px; margin-left: 220px;">
                 <asp:Button ID="bthRefresh" runat="server" Text="" OnClick="bthRefresh_Click" CssClass="invisible" ClientIDMode="Static" />
             <br />
         <asp:HiddenField ID="hdnHasLoaded" runat="server" Value="false" ClientIDMode="Static" />

And the CSS is as follows.

 .ace-hidden {
             display: none;
         .ace-invisible {
             visibility: hidden;

The Javascript to trigger the Events are

 $(document).ready(function ($) {
             var $hasLoaded = $("#hdnHasLoaded");
                 if ($hasLoaded.val() === "false") {
                     $("#txtRelatedPages").val($(".ace-relatedpages-value", window.parent.document).val());

The C# (Server Side) code to render the List boxes are as follows.

 protected void Page_Load(object sender, EventArgs e)
         protected void bthRefresh_Click(object sender, EventArgs e)
                // Actually Bind the List boxes here.
             catch (Exception ex)


Here we are making the Page to load first. Then, Bind the values on the appropriate controls. By this way, we are eliminating the feel of delay in page load. The above code is nowhere increases the performance. Just the feel for the end user. Instead of waiting for the page to load, the user can see a “Loading” information. The same can be done with the Loading.gif also. We can see in upcoming articles more about this. And on the next Article, let us see, how to create an Asynchronous WebPart itself. That will definitely increases the performance. It is a kind of Multi Threading Operation.

Happy Coding.

Sathish Nadarajan.

blog comments powered by Disqus

SharePoint Pals

SharePoint Pals, a community portal for SharePoint developers, Administrators and End Users. Let's join hands and share the point together.
Read this on mobile


Angular Js Training In Chennai
Advanced Angular Js training with real world developer scenarios
Angular Js, Web Api and Ionic for .Net Developers
All in one client side application development for .Net developers
Angular Js For SharePoint Developers
Get ready for the future. Its no more just C#

Get Connected

SharePoint Resources

SharePoint 2013 and 2010 Web Parts
Free Web Parts with Source Code for SharePoint Community

SharePoint 2013 Books and Tutorials
Collection of free SharePoint 2013 books and tutorials (eBooks, pdfs)

Supported By

Contribute your article and be eligible for a one month Free Subscription for Plural Sight. The Author of the most popular New Article (published in the previous month) will be awarded with a Free One month Plural Sight Subscription. Article can be sent to in a word document.

Related Resources

Recent Tweets

Twitter October 23, 22:21
How to Add/Remove User Custom Actions (in Site Actions Menu) Programmatically using CSOM PNP in SharePoint -

Twitter October 21, 21:34
How to Add a JS Link Reference to the Display Form or Any other ASPX Programmatically using CSOM PNP in SharePoint -

Twitter October 20, 13:01
How to Add a JS Link Reference to the NewForm and EditForm Programmatically using CSOM PNP in SharePoint Office 365-

Twitter October 12, 12:15
How to Deploy Provider Hosted Apps (Add-Ins) by App Stapling in SharePoint Office 365 -

Twitter October 11, 13:39
How to Deploy Provider HostedApp programmatically using CSOM in SharePoint Office 365 Activating Developer Feature -

Follow us @SharePointPals
Note: For Customization and Configuration, CheckOutRecent Tweets Documentation