自定义进度条

来源:互联网 发布:Android悬浮窗源码 编辑:程序博客网 时间:2024/06/07 12:17

很头疼的进度条!!!

前台代码

<html xmlns="http://www.w3.org/1999/xhtml">  

<head runat="server">  
    <title></title>  
    <script language="javascript" type="text/javascript">
        function set() { //用来设置进度条的长度  
            var obj, Mywidth;
            obj = document.getElementById("processbar");
            Mywidth = obj.style.width;
            Mywidth = Mywidth.replace("px", "");
            Mywidth = parseInt(Mywidth); Mywidth++;
            obj.style.width = Mywidth + "px";
        }
    </script>  
</head>  
<body>  
    <form id="form1" runat="server">  
    <div style="padding: 1px; background-color: #E6E6E6; border: 1px solid #C0C0C0; width: 300px; height: 20px;">  
     <div id="processbar" style="background-color: #00CC00; height: 18px; width: 1px;">  
        
    </div>  
    </div>  
    <asp:Button ID="Button1" runat="server" Text="Button" OnClick="Button1_Click"/>  
    </form>  
</body>  

</html> 


后台代码

protected void Button1_Click(object sender,EventArgs e)
 {
            int i;
            string s="<script>";
            for(i=0;i<300;i++)
            {
                s+="set();";
                s=s+"</script>";
                ClientScript.RegisterStartupScript(ClientScript.GetType(),s+ i,s);
            }

 }


注:还有一点小bug:后台在前台注册script脚本的时候会在页面显示一大堆的脚本执行命令。

本人能力不足有哪位牛人看到后能否给找一下原因所在,谢谢。