asp.net从页面加载背后的代码多次调用jquery函数

时间:2019-02-03 20:23:31

标签: c# jquery asp.net

我正在尝试使用jquery在ASP.NET中构建简单的进度栏。我想从后面传递数据。所以我有简单的div进度栏

<div class="w3-border">
<div class="w3-grey" id="progressBar0" style="height:24px;width:0%">
</div>
</div>

C#方法

protected void btnUpload_Click(object sender, EventArgs e) {
    int p = 0;
    while (p < 100) {

      ClientScript.RegisterStartupScript(this.GetType(), "script" + p, 
          "SetProgressBarProgressAmount(0," + p + ");", true);

   System.Threading.Thread.Sleep(1000);

   p++;
    }

和jQuery

<script type = "text/javascript" language = "javascript" >
function SetProgressBarProgressAmount(id, progress) {
    var progressBarId = 'progressBar' + id;
    progressAmount = progress + 'px';
    var progressDiv = document.getElementById(progressBarId);
    progressDiv.style.width = progressAmount;
} </script>

我正在做一些愚蠢的事情,因为我最终获得了100%的收益,但是之间却一无所获。谢谢。

0 个答案:

没有答案