title: Passing parameters to javascript button click handler
body: <p>I have a small application in MVC4.  It has a grid and every row has two things.
  1) ID
  2) Button</p>
  
  <p>When user click on a button I need to invoke a javascript function passing ID as an parameter.  How can I do this in MVC.  I can eaisly do thin in case of .  Please help</p>
  
  <p>Below is my code.</p>
  
  <pre><code>@model IEnumerable&lt;Models.Asset&gt;
  
  @{
      ViewBag.Title = "Index";
  }
  
  &lt;h2&gt;Index&lt;/h2&gt;
  
  &lt;p&gt;
      @Html.ActionLink("Create New", "Create")
  &lt;/p&gt;
  &lt;table&gt;
      &lt;tr&gt;
          &lt;th&gt;
              Id
          &lt;/th&gt;
  
          &lt;th&gt;
              Show
          &lt;/th&gt;
      &lt;/tr&gt;
  
  @foreach (var item in Model) {
      &lt;tr&gt;
          &lt;td width="80"&gt;
              @item.Id
          &lt;/td&gt;
  
  
          &lt;td&gt;
              &lt;button class="btnView" onclick="myfunction(@item.someProperty)"&gt;Show&lt;/button&gt;
          ///How can I pass @item.someProperty as an parameter to click handler?
          &lt;/td&gt;              
      &lt;/tr&gt;    
  }
  &lt;/table&gt;
  
  
  &lt;div id="imageDisplay"&gt;
  
      &lt;p&gt;
  
      &lt;/p&gt;
  &lt;/div&gt;
  
  @section scripts{
      &lt;script type="text/javascript"&gt;
          $(function () {
              $('#imageDisplay').dialog({
                  autoOpen: false
              });
  
              $('.btnView').click(function () {
                  alert('ok');
                  //How can I get id as an parameter to this function?
              });            
  
          });
  
      &lt;/script&gt;
  }
  </code></pre>