Web parts that retrieve data from across the network without asynchronous processing, our web parts will have serious limitations when it comes to optimizing page response.
For achieving the optimization factor in page response you need to use the asynchronous processing support provided by the ASP.NET Framework.
For implementing asynchronous in our web parts, we have more than one way
1- Using CallBackEventHandler interface.
2- Using ASP.NET AJAX.
Here, we will implement asynchronous using update panel and AJAX. Firstly, our example is a web part connects to YAHOO! Finance web service for retrieving data about stock exchange.
1- Visual Studio 2010.
2- SharePoint Server 2010.
Creating Stock exchange Web Part
As we said above our web part will connect to internet web service which will have limitations in page response so for avoiding this limitation we need to load
Here, for optimizing page response we want to load the entire page firstly then load all of the important parts on the page first and then load the slower loading part(s) later. While the page is loading, placeholders are displayed to indicate that additional content is coming. After the page loads, the content for the placeholders is retrieved and displayed asynchronously.
1- Create New Project with Visual Studio 2010.
2- Select Visual Web Part project Template.
3- Open user control file.
4- Add to user control, Update panel from toolbox.
5- Now, we create the first view which represents Loading Process
6- Create the second view which represents content view, this view contains fields for each of Stock Symbol, Date, Index Value, and image for value.
7- Add ASP timer control for doing the post back to start connecting to remote web service for retrieving the Stock Exchange value.
8- In The ASP:Timer’s OnTick event — triggered 1ms after the page loads — triggers the routine to load Stock Exchange
This our web part logic
Full Code Shot:-