Click here to Skip to main content
15,033,303 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
Iam uploading the file.

When page is gets refreshing my fileupload is clearing.

I write the below code in page load but it is not working.



Session["path"] = FileUpload1.FileName;

give me suggestions to clear the problem.

[EDIT] oops.... i wants to clear it once upload complete....Yaar! but on page refresh its again showing hasfile true...??? [/EDIT]
Updated 19-Dec-11 5:55am
Uday P.Singh 25-Jul-11 7:17am
what are you trying to achieve?

You can't retain the value of a file upload control, it will be empty every time the page is rendered. Why do you want to retain it's value ?
Member 7932936 25-Jul-11 8:00am
because i don't want to upload the file many times when page gets refreshed
[no name] 25-Jul-11 14:24pm
The file does not get uploaded when the page is refreshed, it is uploaded only when the page is submitted, that is why it gets cleared after a submit.
you cant do that. once the page is reloaded it will lose the file name
Use enctype="multipart/form-data" in form tag.

<form id="form1" runat="server" enctype="multipart/form-data"> This maintain your value.

you can store that information in Session variable once you get in your Fileuploader control.

hope that will be helpful.


This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900