title: Trying to fire .aspx C# function from javascript
body: <p>I'm working on a web application and I need to fire a c# function from my code behind when a tree button is pressed on the page. I found some code that finds the node for me, However, the c# function doesn't seem to be recognized when trying to call it from JS.</p>
  
  <pre><code>&lt;script type = "text/javascript"&gt;
  
  function OnLoad() {
     var links = document.getElementById("&lt;%=navTree.ClientID %&gt;").getElementsByTagName("a");
     for (var i = 0; i &lt; links.length; i++) {
       links[i].setAttribute("href", "javascript:NodeClick(\"" + links[i].id + "\", \"" + links[i].getAttribute("href") + "\")");
     }
  }
  
  window.onload = OnLoad;
  
  function NodeClick(id, attribute) {
    //Do Something
    alert(nodeLink.innerHTML + " clicked" + PageMethods.node_Click());         
    eval(attribute);
  }
  
  &lt;/script&gt;
  </code></pre>
  
  <p>and here's my C# code:</p>
  
  <pre><code>[WebMethod]
  public static string node_Click()
  {
    return "@#$";
  }
  </code></pre>
  
  <p>If I remove the PageMethods.node_Click() call from the alert then it works fine, but not with the call. I also noticed when typing PageMethods. my function doesnt appear on the pop list after the period (in VS)</p>
  
  <p>Any ideas?</p>
  
  <p>Also, heres my cs file:</p>
  
  <pre><code>public partial class SiteMaster : MasterPage
  {
    protected void Page_Load(object sender, EventArgs e)
    {
    }
  
    [WebMethod]
    public static string node_Click()
    {
      return "@#$";
    }
  }
  </code></pre>