title: How to convert List in c# to array in javascript and check the array item
body: <p>I have list in model and the item from database. I want put the item to array in java script. then when I put values in textbox and click the button the system check from the array the values have in array or not </p>
  
  <p>when I try this code, its not work. Any ideas or suggestion?</p>
  
  <p><strong>Model:</strong></p>
  
  <pre><code>public List&lt;string&gt; listponumber { get; set; }
  
  public void getlist()
          {
              var listpo = new List&lt;string&gt;();
              SqlConnection connection = new SqlConnection(System.Configuration.ConfigurationManager.ConnectionStrings["dbconnection"].ConnectionString);
              connection.Open();
  
              SqlCommand cmdponumber = new SqlCommand("Select DISTINCT ponumber From t_transaction ORDER BY ponumber", connection);
  
              SqlDataReader rdr = cmdponumber.ExecuteReader();
              while (rdr.Read())
              {
                  listpo.Add(rdr.GetString(0).ToString());
              }
  
              connection.Close();
              listponumber = new List&lt;string&gt;(listpo);
          }
  </code></pre>
  
  <p><strong>View:</strong></p>
  
  <pre><code>&lt;script type="text/javascript"&gt;
  
      $(document).ready(function () {
  
          $("#btntest").click(function () {
              var ponumber = [@Model.listponumber]
              var txtvalues = document.getElementByID("textbox").value;
              if (ponumber.indexOf(txtvalues) &gt; -1 ) {
                  alert('Array');
              } else { 
                alert('not array');
              }
          });
  &lt;/script&gt;
  </code></pre>