title: Calling a static method from cshtml file
body: <p>I'm trying to work on a clickable DIV  from some vertical tab panel. What I want is when clicking on a specific DIV call a static method to do some tasks, so I did this:</p>
  
  <pre><code>&lt;div class="tabbable tabs-left"&gt;
  &lt;ul class="nav nav-tabs"&gt;
    &lt;li onclick="myEvent()"&gt;&lt;a href="#b" data-toggle="tab"&gt;Tuttle&lt;/a&gt;&lt;/li&gt;
  </code></pre>
  
  <p>then, my JavaScript code:</p>
  
  <pre><code> &lt;script&gt;    
        function clickEvet() {    
        alert("alert test message");   
        @MyProject.myMethod()    
      }   
  &lt;/script&gt;    
  </code></pre>
  
  <p>Calling the function "clickEvent()" works. The problem is that @MyProject.myMethod() is called no matter what, in other words,  @MyProject.myMethod() is being executed as soon the page loads. I want it only when I click on my div.</p>
  
  <p>This is from a cshtml file and I'm using .net 4.5</p>
  
  <hr>
  
  <p>SOLUTION:</p>
  
  <p>I'm editing my question to post the answer for future references...:
  Thanks to other comments I finally understood how to work with Ajax and make it work. Here is the solution:           </p>
  
  <pre><code> &lt;script&gt;     
             function vaxGUID() {          
          $.ajax({
              type: 'POST',
              url: "/VAXBean/bmx",
              data: '{"Name":"AA"}',
              contentType: 'application/json; charset=utf-8',
              dataType: 'html',
              success: function (data) {                    
                  bmx = "http://www.vitalbmx.com";
                  $('a.varURL').attr('href', bmx);
                  GUID = data;                    
                  alert("Good response - " + data + " - " + bmx);
              },
              error: function (data, success, error) {
                  alert("Error : " + error);
              }
          });
          return false;
      }
  &lt;/script&gt;
  </code></pre>
  
  <p>With this Ajax method I'm making the call to some static method in the background       </p>