title: asp.net call jquery function multiple times from code behind with page load
body: <p>I'm trying to build simple progress bar in ASP.NET with jquery. I would like to pass data from method from behind. So I have simple div progress bar</p>
  
  <pre><code>&lt;div class="w3-border"&gt;
  &lt;div class="w3-grey" id="progressBar0" style="height:24px;width:0%"&gt;
  &lt;/div&gt;
  &lt;/div&gt;
  </code></pre>
  
  <p>C# method</p>
  
  <pre><code>protected void btnUpload_Click(object sender, EventArgs e) {
      int p = 0;
      while (p &lt; 100) {
  
        ClientScript.RegisterStartupScript(this.GetType(), "script" + p, 
            "SetProgressBarProgressAmount(0," + p + ");", true);
  
     System.Threading.Thread.Sleep(1000);
  
     p++;
      }
  </code></pre>
  
  <p>and jQuery</p>
  
  <pre><code>&lt;script type = "text/javascript" language = "javascript" &gt;
  function SetProgressBarProgressAmount(id, progress) {
      var progressBarId = 'progressBar' + id;
      progressAmount = progress + 'px';
      var progressDiv = document.getElementById(progressBarId);
      progressDiv.style.width = progressAmount;
  } &lt;/script&gt;
  </code></pre>
  
  <p>I'm doing something stupid because I'm getting 100% on the end but nothing between. Thank you.</p>