title: Populating global variable in razor view using JQuery (MVC)
body: <p>Please see code below:</p>
  
  <pre><code>@{
      var propertyList = new List&lt;Tuple&lt;string, string&gt;&gt;();
  }
  
  &lt;input type="text" data-id="@item.Item1" class="form-control prop"/&gt;
  
  &lt;a class="btn btn-default" id="run-report" href="@Url.Action("RunReport", "Reports", new {reportId = Model.ReportId, propList = propertyList})"&gt; Run Report&lt;/a&gt;
  
  &lt;script&gt;
      $("#run-report").click(function () {
          $(".prop").each(function () {
              var currentProp = $(this).attr("data-id");
              var currentPropVal = (this).value;
  
              @{
                  propertyList.Add(new Tuple&lt;string, string&gt;("", ""));
              }
  
          });
      });
  
  &lt;/script&gt;
  </code></pre>
  
  <p>As you can see above, I have a global variable called <code>propertyList</code> containing a list of tuples, <code>&lt;string, string&gt;</code>.</p>
  
  <p>I declare this here because I need to use the <code>Url.Action</code> to download a report direct to the browser from my controller action.</p>
  
  <p>I have hit a bit of a wall when I get the values from my text box.  I need to add the values from my jQuery to my global list of tuples.</p>
  
  <p>It doesn't look like I can do it this way.</p>
  
  <p>Any advice would be much appreciated!</p>
  
  <p>Thanks</p>