Click here to Skip to main content
16,012,316 members
Please Sign up or sign in to vote.
3.50/5 (2 votes)
See more:
Hi all I have used fileupload control and written code to upload the file in my page load event.But when i submit the form and go to next page and their iam clicking back button to come to the first page.Although i uploaded the file first time it is still asking me upload the file when i return back.What is the solution so that it should save the earlier file which i uploaded and should not ask me again to upload the file.
Posted

You simply need to maintain the state of the upload. If and once you upload a file, keep a session flag like Session["IsUploaded"] = true;

Now, before checking for the upload, all you need is to see the value of this Session field first. If you find it as set true, then pass on the verification/validation check and move on to next page.

UPDATE:
I re-read the question and it sounded like you have the validation check on client side. (since you said it is the case of browser back button). Browser back button works on browsers cache and the page is not reloaded until asked. Either reload the page or keep the flag tracking the upload on client side and update it once uploaded. Try out which one works for you.
 
Share this answer
 
v2
Hi vijay,

your problem is page post back so once check the following is page load

if (!IsPostBack)

and also better to change ur file upload from page load to some other event.


Happy Codding...:)

Seshu
 
Share this answer
 
v2
Comments
Sandeep Mewara 9-May-11 0:56am    
How is this going to help? This is of no use here.

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