title: MVC 4 button onClick that is calling razor function
body: <p>I have MVC 4 application. Here is the case:<br>
  1. Model HashKey - containing 1 string key<br>
  2. Model ModelObjectA - my object to transport.<br>
  3. Class A - generate unique key on request and put it in TempData along with the given  ModelObjectA and returns this unique key.<br>
  4. Controller ControllerModelObjectA - serve as as pure controller.<br>
  5. View ShowAllModelObjectA - view page to display the collection from controller.  </p>
  
  <p>How this works. I have request to navigate to ShowAllModelObjectA. The controller call the class A with the object to transfer and sends the unique key to the ShowAllModelObjectA. The view calls method to get (not HttpGET) the object coresponding to the received key from controller. This collection of object is received and in @foreach loop disassembles the objects and put them in a table. Along with the object in the table is putted also 3 buttons that represents different functions (View details, edit, delete) to corresponding object.  </p>
  
  <p><strong>The problem</strong>:
  On each object`s button i have to use a @functions to call ClassA and send the object itself, but ONLY on click not on for loop.</p>
  
  <p>Here is some code (i have change the names :) )</p>
  
  <pre><code>@functions{
      public string ButtonClicked(ModelObjectA object)
      {
          System.Diagnostics.Debug.WriteLine("in");// to check when the method is called
          return "dae";
      }
  }
  
  The foreach loop:
  
   &lt;table&gt;
              @foreach (ModelObjectA  Object in ModelObjectACollection)
              {
              &lt;tr&gt;
                  &lt;td&gt;
                      @Html.DisplayFor(modelItem =&gt; Object.Name)
                  &lt;/td&gt;
                  &lt;td&gt;
                      @Html.DisplayFor(modelItem =&gt; Object.Email)
                  &lt;/td&gt;
                  &lt;td&gt;
                      &lt;button type="button" id="details" value="@Object" onclick="hello(value);"&gt;Details&lt;/button&gt;
                      &lt;button type="button" value="@Object"&gt;Edit&lt;/button&gt;
                      &lt;button type="button" value="@Object"&gt;Delete&lt;/button&gt;
                  &lt;/td&gt;
              &lt;/tr&gt;
              }
      &lt;/table&gt;
  
  &lt;script type="text/javascript"&gt;
      function hello(Value) {
        alert("Clicked");
      }
   &lt;/script&gt;
  </code></pre>
  
  <p>Since now i have access to the @ModelObjectA but i cant send it to the razor function, because java is on client side and razor on server.</p>
  
  <p>Is there another way to make this?</p>
  
  <p>EDIT:
  Here is the rentered buttons:</p>
  
  <pre><code> &lt;td&gt;
  
                      &lt;button type="button" id="details" value="(Project path).ModelObjectA" onclick="hello(value);"&gt;Details&lt;/button&gt;
                      &lt;button type="button" value="(Project path).ModelObjectA"&gt;Edit&lt;/button&gt;
                      &lt;button type="button" value="(Project path).ModelObjectA"&gt;Delete&lt;/button&gt;
                  &lt;/td&gt;
  </code></pre>
  
  <p>EDIT 2: I am not sure what i need to use to fulfill that requirement. I am open for suggestions.</p>