Click here to Skip to main content
15,888,521 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi everyone,Could any one help how to show the loader image when the data is loading ?I did a sample one which is not a perfect one.Please suggest me the best way .I have a question can we use jquery or javascript?Here when i click the load the data has to load to GV in between this process the preloader has to be visible like in GMAIL.


XML
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Loader Image While Loading Data in GV.aspx.cs"
    Inherits="Loader_Image_While_Loading_Data_in_GV" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title>Loader Image While Loading Data in GV</title>
</head>
<body>
    <form id="form1" runat="server">
    <div>
        <table>
            <tr>
                <td>
                    <asp:Image ID="load_img" runat="server" Height="70px" Width="70px" ImageUrl="~/Images/ajax-loader_green.gif"
                        Visible="false" />
                </td>
            </tr>
            <tr>
                <td>
                    <asp:Button ID="btnload" runat="server" Text="Load" OnClick="btnload_Click" />
                </td>
            </tr>
            <tr>
                <td>
                    <asp:GridView ID="gv1" runat="server" BackColor="LightGoldenrodYellow" BorderColor="Tan"
                        BorderWidth="1px" CellPadding="2" ForeColor="Black" GridLines="None">
                        <AlternatingRowStyle BackColor="PaleGoldenrod" />
                        <FooterStyle BackColor="Tan" />
                        <HeaderStyle BackColor="Tan" Font-Bold="True" />
                        <PagerStyle BackColor="PaleGoldenrod" ForeColor="DarkSlateBlue" HorizontalAlign="Center" />
                        <SelectedRowStyle BackColor="DarkSlateBlue" ForeColor="GhostWhite" />
                        <SortedAscendingCellStyle BackColor="#FAFAE7" />
                        <SortedAscendingHeaderStyle BackColor="#DAC09E" />
                        <SortedDescendingCellStyle BackColor="#E1DB9C" />
                        <SortedDescendingHeaderStyle BackColor="#C2A47B" />
                    </asp:GridView>
                </td>
            </tr>
        </table>
    </div>
    </form>
</body>
</html>


In the Code behind i wrote like this
<pre lang="cs">using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using AdventureWorksModel;
public partial class Loader_Image_While_Loading_Data_in_GV : System.Web.UI.Page
{
    AdventureWorksEntities awe = new AdventureWorksEntities();
    protected void Page_Load(object sender, EventArgs e)
    {
    }
    protected void btnload_Click(object sender, EventArgs e)
    {
        load_img.Visible = true;
        gv1.DataSource = awe.CountryRegionCurrencies.ToList();
        gv1.DataBind();
        load_img.Visible = false;
    }
}




Posted
Updated 30-Jan-11 23:15pm
v2

1 solution

Your example won't work because you're not using AJAX and your page is executing synchronously.

Try and use an UpdatePanel from the MS AJAX framework:

http://msdn.microsoft.com/en-us/library/bb386454.aspx
 
Share this answer
 
Comments
soni uma 31-Jan-11 5:24am    
Right Answer

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900