ajax实现页面加载进度条显示

源码:

 

客户端:

    <div>
        <asp:ScriptManager ID="ScriptManager1" runat="server" />
        <asp:UpdatePanel ID="UpdatePanel1" runat="server">
        <ContentTemplate>
        <div >
            <asp:Label ID="Label1" runat="server" Text="Label" Width="200"></asp:Label>
        </div>
        <div style=" width:200px; border-right:black 1px ridge; border-top:black 1px ridge; border-left:black 1px ridge; border-bottom:black 1px ridge;">
        <div runat="server" id="ProgressDiv" style="width:1%; background-color:Blue;"></div>
        </div>
            <asp:Timer ID="Timer1" runat="server" Enabled="False" Interval="10">
            </asp:Timer>
        </ContentTemplate>
        </asp:UpdatePanel>
    </div>

 

 

后台代码:

   Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
        If Not IsPostBack Then
            Timer1.Enabled = True'启动timer
        End If
    End Sub

 

'此函数返回目前的进度   

 Protected Function GetStatus() As Int32
        Dim status As Int32 = 0
        If Not Session("status") Is Nothing Then
            status = Convert.ToInt32(Session("status"))
        End If
        status += 1
        Session("status") = status
        If status >= 100 Then
            Timer1.Enabled = False
            Session("status") = 0
        End If
        Return status
    End Function

 

    Protected Sub Timer1_Tick(ByVal sender As Object, ByVal e As System.EventArgs) Handles Timer1.Tick
        Dim status As Int32 = GetStatus()
        ProgressDiv.Style("width") = status.ToString + "%"  'div的宽度等于status
        Label1.Text = ProgressDiv.Style("width")
    End Sub

 

 

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值