title: Call a Javascript Method from code-behind Web Method
body: <p>I have a web method in my code behind:</p>
  
  <pre><code>[System.Web.Services.WebMethod]
  public static string GetStateData(string state)
  {
    //this is where i want to call a javascript method "GetItems"
  }
  </code></pre>
  
  <p>I have a javascript method that retrieves some values for me and I want to get use one of those values in my web method</p>
  
  <pre><code>function GetItems() {
          var variable1= $("#&lt;%=Item1.ClientID %&gt; input:checked");
          var variable2= $("#&lt;%=Item2.ClientID %&gt;").val();
          return [variable1.text(), variable2.val(), variable2];}
  </code></pre>
  
  <p>I've searched for ways to call the javascript method from the web method but every time my search results in how to call a web method from javascript.</p>
  
  <p>I did find this but it was done from the code-behind of a silverlight project and when I tried adding the correct reference to my code-behind it wasn't there</p>
  
  <pre><code>var result = HtmlPage.Window.Invoke("GetItems");
  </code></pre>
  
  <p>Is there a reference I'm missing?</p>
  
  <p>Thanks for your response</p>