title: How to call non static method from web method
body: <p>In my code, previously I save data when a button click, here <code>hdnDisplayOrderSaveData</code> is ASP hidden filed</p>
  
  <pre><code>    protected void btnSaveDisplayOrder_Click(object sender, EventArgs e)
          string data = hdnDisplayOrderSaveData.Value;
          Service service = new Service();
          if (IsSaveStringValid(data))
          {
              bool result = service.SaveServicesDisplayOrder(data);
              if (result)
              {
                  ClientScript.RegisterStartupScript(typeof(Page), "script", "showMessage(1);", true);
              }
              else
              {
                  ClientScript.RegisterStartupScript(typeof(Page), "script", "showMessage(2);", true);
              }
          }
          LoadDisplayOrder();
      }
  </code></pre>
  
  <p>Then I need to move above functionality to web method, So my code as follows,</p>
  
  <pre><code>public partial class ProductAdminSortOrder : BasePage
      {
          private List&lt;int&gt; serviceIds = new List&lt;int&gt;();
  
          protected void Page_Load(object sender, EventArgs e)
          {
              try
              {
                  CheckSession();
                  CheckPagePermissions(Permissions.ServicesAdministrator);
                  LoadDisplayOrder();
              }
              catch (Exception ex)
              {
                  Logger.LogErrorEvent(ex);
                  throw;
              }
          }
  
          /// &lt;summary&gt;
          /// Loads the display order.
          /// &lt;/summary&gt;
          private void LoadDisplayOrder()
          {
  
          }
  
          [WebMethod]
          public static void SaveOrder()
          {
  
              string data = hdnDisplayOrderSaveData.Value;
              Service service = new Service();
              if (IsSaveStringValid(data))
              {
                  bool result = service.SaveServicesDisplayOrder(data);
                  if (result)
                  {
                      ClientScript.RegisterStartupScript(typeof(Page), "script", "showMessage(1);", true);
                  }
                  else
                  {
                      ClientScript.RegisterStartupScript(typeof(Page), "script", "showMessage(2);", true);
                  }
              }
              LoadDisplayOrder();
          }
  
          //protected void btnSaveDisplayOrder_Click(object sender, EventArgs e)
  
          //}
  
          private bool IsSaveStringValid(string data)
          { 
              data = Regex.Replace(data, @"\s+", "");
  
              string[] items = data.Split('#');
  
              if (!IsDataValid(item))
              {
                  return false;
              }
          }
  
          private bool IsDataValid(string[] item)
          {
              if (item.Length != 2)
              {
                  return false;
              }
              else
              {
                  return serviceIds.Any(id =&gt; id == Convert.ToInt32(item[0], CultureInfo.InvariantCulture));
              }
          }
  
      }
  </code></pre>
  
  <p>after that, I'm getting following errors,</p>
  
  <pre><code>An object reference is required for the non-static field, method, or property 'ServicesAdminSortOrder.hdnDisplayOrderSaveData'
  An object reference is required for the non-static field, method, or property 'ServicesAdminSortOrder.LoadDisplayOrder()'
  An object reference is required for the non-static field, method, or property 'Page.ClientScript'
  </code></pre>
  
  <ol>
  <li>I have two questions, is the web method should be <code>static</code></li>
  <li>How can I avoid these errors? </li>
  </ol>
  
  <p><strong>Updated:</strong></p>
  
  <p>how I call web method,</p>
  
  <pre><code>function DeleteKartItems() {     
       $.ajax({
       type: "POST",
       url: 'ProductAdminSortOrder.aspx/SaveOrder',
       data: "",
       contentType: "application/json; charset=utf-8",
       dataType: "json",
       success: function (msg) {
           console.log('success');
       },
       error: function (e) {
           console.log('failed');
       }
       });
  }
  </code></pre>