SharePoint Pals
 | Sign In
Asynchronous WebPart in SharePoint 2013
by Sathish Nadarajan 30 Oct 2014
SharePoint MVP
Today  :   8     Total  :    13929

In the previous article, we saw how to create a feel as Asynchronous loading to the end user without increasing the performance of the page. But there could be a scenario like, in the page, there can be many WebParts. Out of them, a particular WebPart can take a lot of time to load. Hence, till the time, the entire page cannot be rendered as they are loading in a sequence.

To avoid this, and to increase the performance, we can implement asynchronous WebParts on the page. This is nothing but a technique, we can use to load the webpart asynchronously.

As usual, first let us see at a high level, what are the things, which we are going to do to accomplish this functionality.

1. Wrap the content of the webpart inside an Update Panel

2. Keep an asp Timer inside the Update Panel.

3. Don’t write anything on the page load of the webpart

4. Call the Bind methods from the Timer Tick Event.

5. Till the time, keep any Loading Images within a Div.

6. Hence, the user will feel that, the particular webpart alone will be displayed with the Loading Gif image. In the meanwhile, the rest of the webparts will start loading as this contents were placed inside Update Panel.

Let us see step by Step in detail.

1. Create a Visual Studio Empty Solution Project

2. Add a Visual Webpart to the Solution.


3. Now the solution structure will be as follows.


4. Now, open the ASCX file. Update the ASCX file with the UpdatePanel as below.

 <%@ Assembly Name="$SharePoint.Project.AssemblyFullName$" %>
 <%@ Assembly Name="Microsoft.Web.CommandUI, Version=, Culture=neutral, PublicKeyToken=71e9bce111e9429c" %>
 <%@ Register TagPrefix="SharePoint" Namespace="Microsoft.SharePoint.WebControls" Assembly="Microsoft.SharePoint, Version=, Culture=neutral, PublicKeyToken=71e9bce111e9429c" %>
 <%@ Register TagPrefix="Utilities" Namespace="Microsoft.SharePoint.Utilities" Assembly="Microsoft.SharePoint, Version=, Culture=neutral, PublicKeyToken=71e9bce111e9429c" %>
 <%@ Register TagPrefix="asp" Namespace="System.Web.UI" Assembly="System.Web.Extensions, Version=, Culture=neutral, PublicKeyToken=31bf3856ad364e35" %>
 <%@ Import Namespace="Microsoft.SharePoint" %>
 <%@ Register TagPrefix="WebPartPages" Namespace="Microsoft.SharePoint.WebPartPages" Assembly="Microsoft.SharePoint, Version=, Culture=neutral, PublicKeyToken=71e9bce111e9429c" %>
 <%@ Control Language="C#" AutoEventWireup="true" CodeBehind="LeftNavigationWebPart.ascx.cs" Inherits="AsynchronousWebPart.LeftNavigationWebPart.LeftNavigationWebPart" %>
     .ace-invisible {
             visibility: hidden;
 <script type="text/javascript">
 <asp:UpdatePanel ID="panLayout" runat="server">
         <div id="divloadingImage" visible="true" runat="server">
             <br />
             <asp:Image ID="imgLoading" runat="server" ImageUrl="/_layouts/Images/gears_anv4.gif" />
             <br />
         <div id="divContent" visible="false" runat="server">
             <table class="style1">
                     <td class="style4">
                         <asp:Label ID="lblTreeView" runat="server" CssClass="IndexSymbolClass"></asp:Label>
         <asp:Timer ID="timerRSS" Interval="5" runat="server" OnTick="timerRSS_Tick"></asp:Timer>

On the Server side, the code will looks like this.

protected void Page_Load(object sender, EventArgs e) { } private void BindTreeView() { try { lblTreeView.Text = "Treeview Loaded"; } catch (Exception ex) { } } protected void timerRSS_Tick(object sender, EventArgs e) { BindTreeView(); divloadingImage.Visible = false; divContent.Visible = true; timerRSS.Enabled = false; }

When the timer ticks after an interval of 1 second, the controls inside the Update Panel starts rendering. Until then, the GIF image will be shown to the end user.

I added this webpart in a page and on the same page, added a Content Editor WebPart as well.


When the page loads, the content editor webpart will start rendering. This will not wait for the Asynchronous WebPart to complete its loading. After a second, the Bind method for the Async Webpart will get triggered and it will be updated like,


This kind of webparts will be very useful, when we are dealing with Stock exchange sites, wants to fetch values to particular webpart etc.,

Download the Source Code HERE

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 January 15, 00:25
How To Enable Target Value And Actual Value In #D3 Gauge Chart

Twitter January 15, 00:24
How To Open #SharePoint List Hyperlink Column In Modal #Popup Window

Twitter January 15, 00:24
Quick Introduction To #Asp.NetCore And It’s Features

Twitter January 15, 00:22
How To Configure #PerformancePoint Services To Use Secure Store In #SharePoint 2013

Twitter January 15, 00:21
How To Block Or Disable #Office365 Services

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