title: ASP.NET Pass model data to site.js
body: <p>How to pass my model data from index.cshtml in site.js.
  Trying to make Ajax request to View controller with model data.</p>
  <p>I have model:</p>
  <pre><code>public class ParticipantDataList
  {
      public List&lt;ParticipantData&gt; Data { get; set; }
  }
  </code></pre>
  <p>which has ParticipantData in it:</p>
  <pre><code>public class ParticipantData
  {
      public Guid LeadId { get; set; }
  
      public string FIO { get; set; }
  
      public Boolean isSelected { get; set; }
  }
  </code></pre>
  <p>I have tried using HiddenFor to store the model:</p>
  <pre><code>@model Models.ParticipantDataList
  @for (int i = 0; i &lt; Model.Data.Count; i++)
  { 
     @Html.HiddenFor(Model =&gt; Model.Data[i])
  }
  </code></pre>
  <p>or</p>
  <pre><code>@foreach (var participant in Model.Data)
  { 
     @Html.HiddenFor(Model =&gt; Model.Data)
  }
  </code></pre>
  <p>and using it in js:</p>
  <pre><code>var data1 = $(&quot;#Data&quot;).val();
  </code></pre>
  <p>So far I have data1 equals <code>System.Collections.Generic.List 1[Models.ParticipantData]</code> BUT data field equals null or data1 is unidentified</p>
  <p>What did I do wrong, have read countless pages on Stack Overflow, but so far no luck.</p>