62,173
社区成员
发帖
与我相关
我的任务
分享
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Second.aspx.cs" Inherits="AjaxUpdateProgress_Second" %>
<!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">
<asp:ScriptManager ID="ScriptManager1" runat="server"></asp:ScriptManager>
<div>
<asp:UpdatePanel ID="upadte" runat="server">
<ContentTemplate>
<div>
<div runat="server" id="div1">
<asp:UpdateProgress ID="UpdateProgress1" runat="server">
<ProgressTemplate>
<%=str %>
</ProgressTemplate>
</asp:UpdateProgress>
<asp:Button ID="btnLogin" runat="server" Text="登陆" OnClick="btnLogin_Click" />
</div>
<div id="div2" runat="server" style="display:none">欢迎您光临!</div>
</div>
</ContentTemplate>
</asp:UpdatePanel>
</div>
</form>
</body>
</html>
using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
public partial class AjaxUpdateProgress_Second : System.Web.UI.Page
{
protected string str = "正在加载中....";
protected void Page_Load(object sender, EventArgs e)
{
this.DataBind();
}
protected void btnLogin_Click(object sender, EventArgs e)
{
this.str = "加载50%.....";
this.DataBind();
System.Threading.Thread.Sleep(2000);
this.str = "加载100%.....";
this.DataBind();
System.Threading.Thread.Sleep(2000);
//显示结果
this.div1.Style.Add("display", "none");
System.Threading.Thread.Sleep(2000);
this.div2.Style.Add("display", "block");
}
}