title: C#: How to using global variable with Javascript
body: <p>everyone!
  I'm learning ASP.NET MVC and have some question.
  My problem is Passing Data from View to Controller.</p>
  
  <p>This my Code:</p>
  
  <pre><code>@{
      string listID = "";
  }
  </code></pre>
  
  <p>and I try to use this variable:</p>
  
  <pre><code>function SubmitDelete() {
     var listId = "";        
     var x = document.getElementsByName("IsCheck");
     for (var i = 0; i &lt; x.length; i++) {
       if (x[i].checked == true) {
          listId += x[i].value + ", ";
       };
     }
     @listID = listId;
     return listId;
  }
  </code></pre>
  
  <p>Finalize, I want to pass @listID to Controller:</p>
  
  <pre><code>@using (Html.BeginForm("DeleteChecked", "Category", new { listID }, FormMethod.Post)){ }
  </code></pre>
  
  <p>It is simple problem about multi delete with checkbox. 
  Help me, please.</p>