title: How to post webform with file to webmethod using Jquery/Ajax?
body: <p>Is this even possible? I have a webform with certain textboxes etc and a file upload element. I am trying to send the data to webmethod using <code>.ajax()</code> method. 
  It seems to me that it is not possible to send file content to the webmethod in this manner. I am not even able to hit the webmethod.</p>
  
  <pre><code>script type="text/javascript"&gt;
      var btn;
      var span;
      $(document).ready(function (e) {
  
          $('#btnsave').on('click', function (event) {
  
              Submit();
              event.preventDefault();
          });
      })
  
      function Submit() {
  
          $.ajax({
              type: "POST",
              url: "SupplierMst.aspx/RegisterSupplier",
              data: "{'file' : " + btoa(document.getElementById("myFile").value) + ",'biddername':" + document.getElementById("txtsuppliername").value + "}",
              async: true,
              contentType: "application/json; charset=utf-8",
              success: function (data, status) {
                  console.log("CallWM");
                  alert(data.d);
              },
              failure: function (data) {
                  alert(data.d);
              },
              error: function (data) {
                  alert(data.d);
              }
          });
  
      }
      &lt;/script&gt;
  </code></pre>
  
  <p><strong>HTML:</strong></p>
  
  <pre><code>&lt;input id="txtsuppliername" type="text" /&gt;&lt;br /&gt;
  &lt;input type="file" id="myFile"&gt;
  </code></pre>
  
  <p><strong>Code behind :</strong></p>
  
  <pre><code>[WebMethod]
  public static string RegisterSupplier(string file, string biddername)
  {
    // break point not hit
  
    return "a";
  }
  </code></pre>
  
  <p>I have been trying to find solution to this for hours now. Nobody seems to be able help me out on this. Is this even possible using this approch. If not how do I do it? Somebody suggested that I should try to submit entire form instead of passing individual values. </p>