title: How Send Input Text And FileUploud Data Using Ajax
body: <p>How Send Input Text And FileUploud Using Ajax In asp.net C#(Web Forms)?   </p>
  
  <pre><code>&lt;input type="text" id="txtChanelName" class="input-field" runat="server" /&gt;
  
  &lt;input type="file" id="fpImage" class="input-field" runat="server"  /&gt;   
  
  &lt;button id="btnInsertChanel" onclick="return AddChanel(this.value);" 
      value='&lt;%=Session["GroupId"].ToString()%&gt;' &gt;add&lt;/button&gt;
  </code></pre>
  
  <p>And my javascript code as below</p>
  
  <pre><code>&lt;script&gt;
      function AddChanel(groupId) {
          var chanelname = document.getElementById("txtChanelName");
          var file = document.getElementById("fpImage").files[0];
          $.ajax({
              type: "POST",
              url: "../../Ajax/Chanel.aspx/AddChanel",
              data: "{'chanName':'" + chanelname.Value 
                                    + "','groupId':'" + groupId 
                                    + "','image':'" + file + "'}",
              contentType: "application/json; charset=utf-8",
              dataType: "json",
              success: function (msg) {
                  //
              },
              error: function (ex) {
                  alert("err");
              }
          });
      }
  &lt;/script&gt;
  </code></pre>
  
  <p>And my c# code as below</p>
  
  <pre><code>[WebMethod]
  [ScriptMethod(ResponseFormat = ResponseFormat.Json)]
  public static bool AddChanel(string chanName,string groupId, string[] image)
  {
      //Breakpoint
      return true;
  }
  </code></pre>