title: ASP.NET Keep fileupload after postback
body: <p>I'm writing an intranet ASP.NET page using VB.NET. I've run into a particularly nasty problem dealing with handling file uploads. I'll do my best to explain the problem, and perhaps someone can help.</p>
  
  <p>My problem is almost a duplicate of <a href="https://stackoverflow.com/questions/2941200/asp-net-fileupload-control-postback-problems">this one</a>, or <a href="https://stackoverflow.com/questions/968251/retain-value-in-fileupload-control">this one</a>, except (other than the filename) I don't care about sending the file to the server until the other data has been reviewed.</p>
  
  <p>Here's the situation:</p>
  
  <p>Joe Q. Dataentry inputs some data into several fields. The first 3 are drop down, and when he changes the selection, a postback event is fired that queries a database for valid entries for the other drop down selections. After selecting the values, he inputs some other data, chooses a file to accompany the data and clicks the "Update" button. When he hits the button, it fires a postback event that sends the current data to the server to be validated. The data will create a change in the database, so he is presented with a view of the current state, and what it will look like when his changes are made. He can now either confirm or cancel the operation for whatever reason.</p>
  
  <p>Part of the data he will see involves the extension of the file which may be a PDF, or could also be some image file or other document.</p>
  
  <p>Now here's where my problem is - on each postback event, the fileupload dialog is cleared. I was getting around it by creating a temporary file on the first postback and then renaming if he clicks OK or deleting on Cancel... but I need to do a variety of things, based on the previous state of data and the filename. I've tried to keep some session variables to retain the filename, and that works OK for just renaming the file, but for what I need to do it gets unwieldy.</p>
  
  <p>What I want to do is be able to have the postback event to present the changes, and <em>then</em> when the user clicks "OK", submit the file. Is there any possible way to do that? </p>
  
  <p>One of my thoughts was to do some of the validation client-side (I'm already re-validating server side so I'm not too worried about data security there), but I don't know how I could get the information from the database query.</p>
  
  <p>Thanks for any help, and reading my slightly convoluted story/situation!</p>
  
  <hr>
  
  <p><strong>EDIT:</strong></p>
  
  <p>It appears that what I want to do is prevent a certain button from firing a full postback. Is there any way to do that?</p>
  
  <p><strong>EDIT II:</strong></p>
  
  <p>I have an update panel on the page already - is there any way for the button to <em>only</em> post what's in the update panel?</p>