AJAX中的UpdateProgress的用法


UpdateProgress是一個進度顯示條
第一.新建一個AJAX項目。在頁面上加上ScriptManager,UpdatePanel,UpdateProgress,同時在UpdatePanel中加入一個Label,和Button。
第二:選中UpdateProgress的AssociatedUpdatePanelID設置爲UpdatePanel1,完整的HTML代碼如下:
<%@ Register
    Assembly="AjaxControlToolkit"
    Namespace="AjaxControlToolkit"
    TagPrefix="ajaxToolkit" %>
<!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>
</head>
<body>
    <form id="form1" runat="server">
    <div>
        <asp:ScriptManager ID="ScriptManager1" runat="server">
        </asp:ScriptManager>
   
    </div>
        <asp:UpdatePanel ID="UpdatePanel1" runat="server">
            <ContentTemplate>
                &nbsp;<asp:Label ID="Label1" runat="server" Text="Label" Width="166px"></asp:Label>&nbsp;
                <br />
                &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp;
                <asp:Button ID="Button1" runat="server" OnClick="Button1_Click" Text="Button" />
            </ContentTemplate>
        </asp:UpdatePanel>
        <asp:UpdateProgress ID="testUp" runat=server AssociatedUpdatePanelID="UpdatePanel1">
            <ProgressTemplate>
                progressing..
            </ProgressTemplate>
          
        </asp:UpdateProgress>
    </form>
</body>
</html>第三,在BUTTON中加入點擊事件,代碼如下:
 System.Threading.Thread.Sleep(5000);

        Label1.Text =  DateTime.Now.ToString();

發佈了36 篇原創文章 · 獲贊 2 · 訪問量 4萬+
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章