How I can use the UpdateProgress Control for show a waittime

生来就可爱ヽ(ⅴ<●) 提交于 2019-12-04 09:45:42

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>

Try to put your button within an UpdatePanel that contains the code may take a long time to execution, then associate the UpdateProgress control to the UpdatePanel. code you may need is just like:

<asp:UpdatePanel ID="updatePanelMain" runat="server">
<ContentTemplate>
    <asp:button runat="server" ID="btnBenutzerSuchen" OnClick="btnBenutzerSuchen_Click"/>
</ContentTemplate>
</asp:UpdatePanel>

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

Hope this helps. :)

I did a small example simulation a button click within an updatePanel. Pay attention to the attribute AssociatedUpdatePanelID which must be set, in order to show your progressTemplate.

default.aspx

<asp:ScriptManager ID="ScriptManager1" runat="server">
</asp:ScriptManager>
<asp:UpdatePanel ID="UpdatePanel1" runat="server">
<ContentTemplate>
    <asp:Button ID="btnDoSomething" runat="server" Text="Do Something" 
        onclick="btnDoSomething_Click" />
    <asp:ListView> YOUR_LISTVIEW_GOES_HERE </asp:ListView>
</ContentTemplate>
</asp:UpdatePanel>

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

default.aspx.cs

protected void btnDoSomething_Click(object sender, EventArgs e)
{
    System.Threading.Thread.Sleep(5000);
    // or update listView
}

Show Progress Bar Using UpdateProgress Control in Asp.net

Refer This Link for more information

http://www.freshcodehub.com/Article/22/show-progress-bar-using-updateprogress-control-in-aspnet

<asp:UpdateProgress ID="prgLoadingStatus" runat="server" DynamicLayout="true">
        <ProgressTemplate>
            <div id="overlay">
                <div id="modalprogress">
                    <div id="theprogress">
                        <asp:Image ID="imgWaitIcon" runat="server" ImageAlign="AbsMiddle" ImageUrl="~/img/progress.gif"
                            Width="230px" /><br />
                        Please wait...
                    </div>
                </div>
            </div>
        </ProgressTemplate>
    </asp:UpdateProgress>
    <asp:UpdatePanel ID="UpdatePanel1" runat="server">
        <ContentTemplate>
            <asp:Button ID="btnProgress" runat="server" Text="Show Progress" OnClick="btnProgress_Click" />            
        </ContentTemplate>
    </asp:UpdatePanel>
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!