enkor
asked on
FileUpload empty after PostBack
Hi experts,
I have problem with the FileUpload. When I choose a file and I want to send it, I press the button. But here I have some conditions (like Captcha etc...). When the PostBack occures I can see the FileUpload values, but if captcha is wrong I dont want to save the file.
But when I look at the FileUpload now, it is empty.
What to do to keep the file path set up into the FileUpload also after PostBack please?
I have problem with the FileUpload. When I choose a file and I want to send it, I press the button. But here I have some conditions (like Captcha etc...). When the PostBack occures I can see the FileUpload values, but if captcha is wrong I dont want to save the file.
But when I look at the FileUpload now, it is empty.
What to do to keep the file path set up into the FileUpload also after PostBack please?
ASKER
I dont need the async uploading, I just need the upload on releasing submitting button. So there is no way to keep the values anyway?
There isn't a way to get the FileUpload control to retain it's value (or set it to a default value) after a postback. Because of security implications (scripts setting the value, and then attempting to retrieve files of your computer) the value of the fileupload form field is read only. Therefore you cannot set or reset the value either through Javascript or through Server Side Code. The only way to set the value on the FileUpload control is to have the user make a selection.
so i think there is no method other than AJAX or IFRAME technique.
so i think there is no method other than AJAX or IFRAME technique.
ASKER
ok, thanx. and can anyone gimme the ajax example please? I am not so strong in it.
Thanx
Thanx
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
The default size for upload is 256bytes. So in your case (uploading files) makes sense to increase that limit.
ASKER
I had no problem with the limit, but it caused error: "Can Not Access A Closed File"
So I have found this: http://www.c-sharpcorner.com/Forums/Thread/43162/can-not-access-a-closed-file.aspx
So I have found this: http://www.c-sharpcorner.com/Forums/Thread/43162/can-not-access-a-closed-file.aspx
It will not retain the value in control if page validation is wrong as like password field.
ASKER
The solution by eugenbv is OK, but did not work me till i have found the <httpRuntime>, so his solution was not absolutely complex.
http://aspalliance.com/144