将数据加载到GridView时,如何显示类似gmail的Loader图像? [英] How to show the Loader image like in gmail when loading Data into GridView?
本文介绍了将数据加载到GridView时,如何显示类似gmail的Loader图像?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
大家好,有人可以帮忙如何在加载数据时显示加载器图像吗?我做了一个示例,这不是一个完美的示例.请建议我最好的方法.我有一个问题,我们可以使用jquery还是javascript?在这里,当我单击加载时,必须在此过程之间将数据加载到GV中,预加载器必须像在GMAIL中一样可见.
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.
<%@ 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;
}
}
推荐答案
您的示例无法使用,因为您没有使用AJAX,并且页面正在同步执行.
尝试使用MS AJAX框架中的UpdatePanel:
http://msdn.microsoft.com/en-us/library/bb386454.aspx
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
这篇关于将数据加载到GridView时,如何显示类似gmail的Loader图像?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文