【问题标题】:How to display gif while GridView Process ASP.NET如何在 GridView 处理 ASP.NET 时显示 gif
【发布时间】:2013-07-17 19:58:48
【问题描述】:

我有一个在 ASP.NET GridView 中显示各种数据的应用程序。值显示为组合框的选择。当我选择组合框时,重新加载过程大约需要 8 秒。我想在开始进程之前显示一个加载的 gif 并结束它取消显示图像。我尝试为此使用线程,但效果不佳。有人可以帮我吗?

protected void Page_Load(object sender, EventArgs e)
    {
        //My Image
        imageLoad.Visible = true;
        Assembly myAsm = Assembly.Load("PainelBordo");
        AssemblyName aName = myAsm.GetName();
        Version version = aName.Version;

        BusinessLogicLayer bll = new BusinessLogicLayer();

        LoadDDLWRTG(CreateDataTableWRTGList());
        LoadDataPBList();

        TimerRefresh.Interval = Convert.ToInt32(ConfigurationManager.AppSettings["TimerInterval"].ToString());

        lblUpdateDate.Text = "Refresh " + bll.DateUpdateFormat(DateTime.Now);
        // My image
        imageLoad.Visible = false;
    }

Combobox SelectedIndexChanged.

protected void ddlWRTGroup_SelectedIndexChanged(object sender, EventArgs e)
    {
        Page_Load(sender, e);
    }

【问题讨论】:

  • 您需要在客户端通过show / hide 加载或发布该图像...
  • 简单的 javascript 就足够了,但一切都取决于你发布的内容和方式......作为“一系列下拉菜单”,我总是会做得更好,作为 ajax 调用,那 8 秒会制作 3...

标签: asp.net multithreading gridview


【解决方案1】:

在 UpdatePanel 中拖放一个 Button(btnInvoke) 和 Label(lblText) 控件。还要在 UpdatePanel 中添加<div id="divImage">。此 div 将包含一个描述进度的 .gif 图像,最初设置为不可见 style="display:none"。在按钮单击时,执行一项耗时的任务。在我们的例子中,我们使用 Thread.Sleep(3000) 设置了 3 秒的延迟

C#

protected void btnInvoke_Click(object sender, EventArgs e)
    {
        System.Threading.Thread.Sleep(3000);
        lblText.Text = "Processing completed";
    }

取自 here

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2013-03-14
    • 1970-01-01
    • 2011-11-06
    • 2017-07-18
    • 2011-01-15
    • 1970-01-01
    • 2016-03-11
    • 1970-01-01
    相关资源
    最近更新 更多