title: FileUpload empty after PostBack
body: <p>I have a problem regarding a ASP.NET fileuploader that is empty after postback. I have one fileupload control, one textbox control and one button control.</p>
  
  <p>When I click the button, it checks if the textbox is populated, if it is it performs actions, if its not then it shows an error message and stay on the page. However, when I press the button and the textbox is empty, the button postsback and the fileuploader is empty and the user has to select the file again. So: User selects file > The file is located in the fileuploader > the user presses the button > the error message pops up > the fileuploader loses the file after postback.</p>
  
  <p>When the user selected a file but not yet clicked the button (koala.jpg)
  <img src="https://i.stack.imgur.com/z1vhz.png" alt="enter image description here"></p>
  
  <p>When the button is pressed, the file is gone (no file selected)<br>
  <img src="https://i.stack.imgur.com/fqqwP.png" alt="enter image description here"></p>
  
  <p><strong>How do I keep a file in the fileuploader after a postback or maybe tell the button not to post back if the textbox is empty?</strong></p>
  
  <p><strong>EDIT:</strong></p>
  
  <p>Be aware that I simplified the question and that the content of the first post are just made up to make my question more clear.</p>
  
  <p>Page load:</p>
  
  <pre><code>    protected void Page_Load(object sender, EventArgs e)
      {
          //First check if User is logged in 
          if (Session["User"] == null)
          {
              Response.Redirect(GetRouteUrl("Login", null));
          }
  
          TicketsBLL objTicketsBll = new TicketsBLL();
  
  
          var cat = objTicketsBll.getAllCategories();
  
          ddlCategory.DataTextField = "name";
          ddlCategory.DataValueField = "id";
          ddlCategory.DataSource = cat;
          ddlCategory.DataBind();
  
  
  
      }
  </code></pre>
  
  <p>Button Click:</p>
  
  <pre><code>//check if everthing is filled :
          errorContent.Visible = false;
          errorSubject.Visible = false;
  
          if (txtSubject.Text == "" || txtSubject.Text == null || txtContent.Text == null || txtContent.Text == "")
          {
              if (txtSubject.Text == "" || txtSubject.Text == null)
              {
                  errorSubject.Visible = true;
              }
              if(txtContent.Text == null || txtContent.Text == ""){
                  errorContent.Visible = true;
              }
          }
  
          else { //Do something after this
  </code></pre>
  
  <p>errorSubject &amp; errorContent are hidden divs that show up as the error </p>