title: System.Web.UI.WebControls.FileUpload' does not contain a definition for 'HasFiles' and no extension method
body: <p>Using asp.net, I want to upload multiple files using single file upload option, but I'm getting, <strong>System.Web.UI.WebControls.FileUpload' does not contain a definition for 'HasFiles' and no extension method</strong> error.</p>
  
  <p>My code:        </p>
  
  <pre><code>&lt;%-- ed: some styles removed for readability. --%&gt;
  &lt;div class="col-md-3"&gt;
      &lt;asp:Label ID="lblattach" runat="server" Text="Attach File:"&gt;&lt;/asp:Label&gt;
      &lt;asp:FileUpload ID="FileUpload1" runat="server" AllowMultiple="true"&gt;&lt;/asp:FileUpload&gt;
  &lt;/div&gt;
  
  if (FileUpload1.HasFiles)
  {
      if (FileUpload1.FileName.EndsWith(".pdf") || 
          FileUpload1.FileName.EndsWith(".PDF") || 
          FileUpload1.FileName.EndsWith(".doc") || 
          FileUpload1.FileName.EndsWith(".DOC") || 
          FileUpload1.FileName.EndsWith(".docx") || 
          FileUpload1.FileName.EndsWith(".DOCX"))
      {
          foreach (HttpPostedFile PostedFiles in FileUpload1.PostedFiles)
          {
              FileInfo TheFile = 
                  new FileInfo(MapPath("~/Ebooks") + "\\" + FileUpload1.FileName);
              if (TheFile.Exists)
              {
                  Label1.Visible = true;
                  Label1.Text = "File '" + FileUpload1.FileName + "' Already Exists";
              }
              else
              {
                  string fileName = Path.GetFileName(PostedFiles.FileName);
                  PostedFiles.SaveAs(Server.MapPath("~/Ebooks") + "\\" + fileName);
                  {
                      Con.Open();
                      string sql1 = "Sp_InsertEbookLinks";
                      SqlCommand cmd = new SqlCommand(sql1, Con);
                      cmd.CommandType = CommandType.StoredProcedure;
                      cmd.Parameters.AddWithValue("@linkName", link);
                      cmd.Parameters.AddWithValue("@fileName", FileUpload1.FileName);
                      cmd.Parameters.AddWithValue("@BatchCode", ddlbatch.SelectedValue);
                      cmd.Parameters.AddWithValue("@CourseCode", ddlcourse.SelectedValue);
                      cmd.Parameters.AddWithValue("@SemesterCode", ddlSemester.SelectedValue);
                      cmd.Parameters.AddWithValue("@SubjectCode", ddlsubject.SelectedValue);
                      cmd.Parameters.AddWithValue("@ActiveInactive", chkbxactinact.Checked);
                      cmd.Parameters.AddWithValue("@lastModUserCod", 1);
                      cmd.ExecuteNonQuery();
                      Con.Close();
                      ScriptManager.RegisterStartupScript(this, GetType(), "Popup", 
                          "Successalert('Data Inserted Successfully');", true);
                      LoadData();
                      txtlink.Text = "";
                      ddlbatch.SelectedValue = "0";
                      ddlcourse.SelectedValue = "0";
                      ddlSemester.SelectedValue = "0";
                      ddlsubject.SelectedValue = "0";
                      Label1.Visible = false;
          }
      }
  }
  </code></pre>