title: Call server side function from Client Side
body: <p>I am using Master and Content page.
  my client side function is-</p>
  
  <pre><code> &lt;script type="text/javascript"&gt;
      function StateChange(txtState) {
          var state = document.getElementById(txtState);
          PageMethods.StateSelectionChange(state.value, OnSuccess, onFailed);
      }
      function OnSuccess(state, userContext, methodName) {
          alert(state);
      }
      function onFailed(state, userContext, methodName) {
          alert(state);
      }
  &lt;/script&gt;
  </code></pre>
  
  <p>and server side code is-</p>
  
  <pre><code> public static string StateSelectionChange(string state)
  {
      //txtCity.Text = "";
      //if (txtState.Text != "")
      //{
      //    SqlDataReader dr = cm.Allstate(txtState.Text);
      //    if (dr.Read())
      //    {
      //        con.Close();
      //        AutoCompleteExtender2.ContextKey = txtState.Text;
      //        txtCity.Enabled = true;
      //        txtCity.Focus();
      //    }
      //    else
      //    {
      //        con.Close();
      //        ScriptManager.RegisterStartupScript(this.Page, this.GetType(), "Alert", "alert('State is not exist');", true);
      //        txtState.Text = "";
      //        txtState.Focus();
      //    }
      //}
      return (state);
  }
  </code></pre>
  
  <p>I am not able to access the commented part (textbox and class main function) of that code because of declaring the function as static. If I remove static word from this function then it shouldn't be called from client side.</p>
  
  <p>Finally I want to call non static function from client side using Java script/ajax request.</p>