preventing upload of file on certain control postback

  • Thread starter Thread starter giant food
  • Start date Start date
G

giant food

I have a simple aspx page with a few controls. One is a standard HTML
File input. In addition I have two DropDownList objects and an
ASP:Button to submit the form. I'm using AutoPostBack on one
DropDownList object to dynamically load the contents of the other
DropDownList server-side.

Problem is, if the user specifies a file to upload and then changes
their choice in the DropDownList, their browser posts back and sends
the entire file.

Since my site has some very large files that take a while to upload,
I'd like to make it so that the file is only sent by the browser when
the user clicks on the ASP:Button.

My initial solution idea is to add some javascript which clears out
the file input field if the DropDownList was changed. Any other
suggestions?

--Frank
 
set a session variable that is the filename. So,

If session("UploadedFile") <> control.PostedFile.FileName then
upload the file
session("UploadedFile") = control.PostedFile.FileName
end if
 
Back
Top