Link to home
Start Free TrialLog in
Avatar of enkor
enkorFlag for Czechia

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?
Avatar of mayank_joshi
mayank_joshi
Flag of India image

Avatar of enkor

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.
Avatar of enkor

ASKER

ok, thanx. and can anyone gimme the ajax example please? I am not so strong in it.
Thanx
ASKER CERTIFIED SOLUTION
Avatar of eugenbv
eugenbv
Flag of Romania image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
The default size for upload is 256bytes. So in your case (uploading files) makes sense to increase that limit.
Avatar of enkor

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
Avatar of Alpesh Patel
It will not retain the value in control if page validation is wrong as like password field.
Avatar of enkor

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.