views:

613

answers:

2

I m using asp.net 2.0 without AJAX. The file path in the fileupload control gets vanished once the postback take places. i do some validations for other controls in code behind. i need to upload the file again for further processing. can any one suggest me how to hold the filepath in the fileupload control even after postback.

+1  A: 

It's not possible, for security reasons. You cannot set the field on the client side, and it will not stay set, after you post. The security reason is that, if it were allowed to be set, you could arbitrarily upload any file from the users computer, which would be bad.

Noon Silk
+1  A: 

I agree with Silky. FileInput control cannot hold value across post backs.

A possible workaround for this can be how GMail handles uploading attachments. The file can be placed in some temporary location on server and after the post back, display a label indicating that the file is already selected and provide a remove button. A problem here is that you have to consider cleaning up such files.

Vijay
thanks for ur suggestions. i ll try to work around in this concept, actually i m new to this asp.net so i find it difficult to manage, thanks again.
GayaMani