title: FileUpload.PostedFile is always null unless the page has posted back at least once?
body: <p>Seems like an obvious question but I'm still confused. I have an asp FileUpload control on the page which also happens to be inside of an UpdatePanel. I have the UpdatePanel set to UpdateMode="Conditional". I also have a postback trigger (not an asyncpostback trigger) set in the triggers section. On button click, it is supposed to upload the file to a database, handled in my datalayer. On the first attempt, it will fail as the PostedFile is null, but you see the page perform a postback (which inherently clears/resets the download control). When I try uploading a file again, it is fine. My first thought was because it needed to postback in order to actually grab the bytes, right? Well ok, so under that logic, I figured if I attempted to upload a different file, then it would actually upload the previous file. It did not; it uploaded the new file. So that's where I'm confused.</p>
  
  <p>Here's the upload method:</p>
  
  <pre><code>protected void ReplaceDoc()
  {
      var data = ulReplaceDoc.FileBytes;
      var fileName = ulReplaceDoc.PostedFile.FileName;
      if (MocApi.ReplaceWorkingDocument(_request.MocRequestID, _currentUser, fileName, data))
      {
          //refresh files
          ShowFiles();
      }
  }
  </code></pre>
  
  <p>Pretty straight forward. It is supposed to grab the file, upload it (which runs an UPDATE query on the database to change the file), then it refreshes a datasource to show the new file.</p>
  
  <p>So my question is this: Why does it only fail on the first try? Also, what would be a better way to achieve this effect?</p>