本文介绍了如何使用UpdateProgress控件显示等待符号?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个带ListView的ASP.NET应用程序.我从Active Directory中获取数据,现在如果要构建ListVew,则需要一个等待符号.我以为我会使用Ajax控件工具包中的UpdateProgress控件.但是我不知道如果单击并且ListView完成时等待符号(例如gif)关闭,我将如何使用它. :(

I have an ASP.NET application with a ListView. I get data from Active Directory and now I want a wait symbol for the time if the ListVew is building. I thought I would use a UpdateProgress Control from Ajax Control toolkit. But I don't know how I can use it if I click on a Button and the wait symbol (for example a gif) closes if the ListView is finished. :(

我的CS文件:

protected void btnBenutzerSuchen_Click(object sender, EventArgs e)
{
     //If I click on this Button the gif must start

    try
    {
        ... // my ListView get data

        this.myListView.DataSource = dv; 
        this.myListView.DataBind();

        ...

    }
    catch (Exception)
    {
        ...
    }

   //If the ListView is finish the gif must close 
}

我该怎么做?我可以这样使用UpdateProgress来做到这一点:

How I can do this? Can I do this with the UpdateProgress like this:

<asp:UpdateProgress ID="UpdateProgress1" DynamicLayout="true" runat="server" AssociatedUpdatePanelID="?" >
    <ProgressTemplate>
    <div class="progress">
        <img src="images/ajax-loader-arrows.gif" />&nbsp;please wait...
    </div>
    </ProgressTemplate>
</asp:UpdateProgress>

我的update.aspx文件:

My update.aspx file:

<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="~/BenutzerListe.aspx.cs" Inherits="BenutzerListe.BenutzerListe" %>
<%@ Register TagPrefix="asp" Namespace="AjaxControlToolkit" Assembly="AjaxControlToolkit"%>

<!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></title>

    <script src="Scripte/jquery-1.7.2.js" type="text/javascript"></script>
    <script type="text/javascript" src="Scripte/jquery-ui-1.8.22.custom.min.js" ></script>

    <script language="javascript" type="text/javascript">

// my javascript code

    </script>

     <link href="~/App_Theme/BenutzerListeStyle.css" type="text/css" rel="Stylesheet" />
     <link href="App_Theme/jquery-ui-1.8.22.custom.css" type="text/css" rel="Stylesheet" />
     <link href="App_Theme/PopUpDialog_Style.css" type="text/css" rel="Stylesheet" />

    <style type="text/css">
        #SuchTabelle
        {
            width: 587px;
        }
    </style>

</head>

<body>
    <form id="form1" runat="server">

    <asp:scriptmanager id="ScriptManager1" runat="server">
       </asp:scriptmanager> 

           <div class="header">
           <br />

        <table id="SuchTabelle" class="SuchTabelle" runat="server" border="0" width="100%">
            <tr>
                <th><asp:Label ID="id_SearchUser" runat="server" Text="lblSearchUser"></asp:Label></th>
                <th class="txtBenutzerSuchen"><asp:TextBox ID="txtBenutzer"  runat="server" Width="150px" ToolTip="Gesucht wird nach Vorname, Nachname, eMail , Abteilung und Telefonnummer"></asp:TextBox></th>
                <th><asp:Label ID="id_location" runat="server" Text="lblLocation"></asp:Label></th>
                <th class="DropDownList"><asp:DropDownList ID="dropWerk" runat="server" Width="200px" /></th>
                <th>

                        <asp:Button  ID="Button2" runat="server" Text="Suchen" onclick="btnBenutzerSuchen_Click" Width="150px"/>

                </th>
            </tr>
        </table>

      </div>

           <div class="bodyList">

           <asp:UpdatePanel ID="update" runat="server">
            <ContentTemplate>

                <asp:ListView> .... </asp:ListView>

            </ContentTemplate>
           </asp:UpdatePanel>

           <asp:UpdateProgress ID="updatePro" DynamicLayout="true" runat="server" AssociatedUpdatePanelID="update">
            <ProgressTemplate>
               <asp:Image ImageUrl="~/App_Theme/ajax_loader_circle.gif" runat="server" ID="waitsymbol" />
            </ProgressTemplate>
           </asp:UpdateProgress>

        <hr />
    </div>

    </form>
</body>
</html>

推荐答案

首先将您的listview aspx代码放在更新面板中

First place your listview aspx code inside an update panel

<asp:UpdatePanel ID="up" runat="server">
    <ContentTemplate>
        // Place your list View Code here
        <asp:ListView ..........
         ...... </asp:ListView>
    </ContentTemplate>
    <Triggers>
       // If button is present outside update panel then specify AsynPostBackTrigger
       <asp:AsyncPostBackTrigger ControlID="btnControlID" EventName="Click" /> 
    </Triggers>
</asp:UpdatePanel>

// Now Set AssociatedUpdatePanelID="up" in the UpdateProgress

<asp:UpdateProgress ID="UpdateProgress1" DynamicLayout="true" runat="server"  AssociatedUpdatePanelID="up" >
<ProgressTemplate>
<div class="progress">
    <img src="images/ajax-loader-arrows.gif" />&nbsp;please wait...
</div>
</ProgressTemplate>
</asp:UpdateProgress>

这篇关于如何使用UpdateProgress控件显示等待符号?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-28 23:31