title: How to Clear the hasfile Property on an asp:FileUpload Control?
body: <p>I have a .NET 2.0 fileupload control, and next to it a button, like this:</p>
  
  <pre><code>&lt;asp:fileupload id="uploadedFile" runat="server" /&gt;
  &lt;asp:Button runat="server" ID="upload" Text="Upload" OnClick="Page_Load"/&gt;
  </code></pre>
  
  <p>Now, this is all on a page within a webpart (sharepoint, that is - for those of you unfamiliar with webparts - it is basically an iframe).  Notice also that I am calling Page_Load.</p>
  
  <p>After the user browses for the file, the <code>hasfile</code> property of the <code>uploadedFile</code> control becomes <code>true</code> (it was <code>false</code> to begin with).  Fine.  The user clicks the button and the file uploads.  I have code in there that sends me an email to let me know a file has been uploaded as long as <code>hasfile</code> is <code>true</code>.</p>
  
  <p>If the user pushes the refresh button in his browser, the page is reloaded, but the <code>hasfile</code> property is not cleared, and so I get sent another email!  (If I use Firefox's ability to reload without the cache, then everything is refreshed correctly)</p>
  
  <p><em>How can I clear the <code>hasfile</code> property on the FileUpload control?</em> Or how can I cause the page to skip the cache when the user reloads?</p>
  
  <p>I don't mind calling a function other than Page_Load, but then it needs to be able to receive a parameter so I can also call it from Page_Load (on account of other things I am doing).</p>