title: Counting how many times a button was clicked
body: <p>I am wondering how can I count the number of times a button in my view was clicked using <code>sessions</code> and not using jQuery, just asp.net.</p>
  
  <p>Here is my action method (empty) : </p>
  
  <pre><code> public ActionResult ClickCounter()
          {
              return View();
          }
  </code></pre>
  
  <p>and my view : </p>
  
  <pre><code> @{
      ViewBag.Title = "ClickCounter";
  }
  
  &lt;h2&gt;ClickCounter&lt;/h2&gt;
  
  @using (@Html.BeginForm())
  {
      &lt;!-- form content here --&gt;
      @Session["num"] = 0;
      &lt;form method="post"&gt;
          &lt;fieldset&gt;
              &lt;legend&gt;Button clicks counter&lt;/legend&gt;
              &lt;div&gt;
                  &lt;label for="Clciks"&gt;Clicks:&lt;/label&gt;
  
                 &lt;h2&gt;@Session["num"]&lt;/h2&gt;
              &lt;/div&gt;
              &lt;div&gt;
                  &lt;label&gt;&amp;nbsp;&lt;/label&gt;
                  &lt;input type="submit" value="Click!" class="submit" /&gt;
              &lt;/div&gt;
          &lt;/fieldset&gt;
      &lt;/form&gt;
  }
  </code></pre>
  
  <p>Excuse me for the lame questions, but I am a complete novice and trying to understand how this stuff work. I tried googleing.
  I just want to display the click count in the h2 in my view using sessions for the purpose.</p>
  
  <p>Any tips will be appreciated.</p>