How to assign value to a static variable in a non-static function?
<p>Basically, <code>ajax</code> in aspx is polling the value return from .cs every 1000 ms from a <code>WebMethod</code> in .cs which is <code>static GetData()</code>. A property is declared as static <code>public static int Percent { get; set; }</code> . What i want to do is when a btn1 is clicked, it will assign the value into <code>Percent</code> and the <code>ajax</code> get the value from the <code>WebMethod static GetData()</code>.</p>

<h2>Downloader.aspx.cs</h2>

<pre><code>public static int PERCENT { get; set; }

[WebMethod]
public static string GetData()
{
     return PERCENT ;
}

protected void btn1_Click(object sender, EventArgs e)
{
     DownloadLibrary downloader = new DownloadLibrary();
     downloader.DoWorkSynchronous();
     bool isLibraryBusy = true;
     while (isLibraryBusy)
     {
        PERCENT  = library.returnValue();
        isLibraryBusy = downloader.IsBusy();
     }
}
</code></pre>

<h2>Downloader.aspx (ajax polling)</h2>

<pre><code>    $(document).ready(function() {
        $("#progressbar").progressbar();
              setTimeout(updateProgress, 100);
    });

   function updateProgress() {
              $.ajax({
                  type: "POST",
                  url: "Downloader.aspx/GetData",
                  data: "{}",
                  contentType: "application/json; charset=utf-8",
                  dataType: "json",
                  async: true,
                  success: function(msg) {
                      // Replace the div's content with the page method's return.

                      $("#progressbar").progressbar("option", "value", msg.d);
                  }
              });
          }
</code></pre>

<p>I want to assign the value to <code>Percent</code> but unfortunately,i am unable to do it because the <code>Percent</code> is <code>static</code>. If i don't declare the <code>Percent</code> as <code>static</code>, the <code>GetData</code>() function unable to verify what <code>Percent</code> is. For <code>ajax</code> polling, <code>GetData()</code> have to be in <code>static</code>. How to assign value to a <code>static</code> variable in a <code>non-static function</code>?</p>
