title: How to call a static method from a button click asp.net
body: <p>I have a method that follows:</p>
  
  <pre><code>public static void UpdateAll()
      {
         // Updates database
      }
  </code></pre>
  
  <p>and I have a MVC Application, the view is as follows (removed lines for clarity):</p>
  
  <pre><code>&lt;button id ="btn"&gt;Update&lt;/button&gt;
  //...
  &lt;script&gt;
      $('#btn').click(function () {
          @{
             project.models.settings.UpdateAll();
           }
      });
  &lt;/script&gt;
  </code></pre>
  
  <p>The <em>project.models.settings.UpdateAll()</em> method fires as soon as the page loads. Is there a way of making this method load, only once the user has clicked the button? </p>
  
  <p>To test I did replace the method with a simple console.log and that worked as intended.</p>
  
  <p>Any pointers, examples are much appreciated.</p>
  
  <p>Kind regards</p>