Johny Bravo
asked on
AsyncFileUpload loses file
Hi I am using AsyncFileUpload control to upload images of Employees.
The employee information form has various fields including this.I have some dropdowns on the form which causes postback,
but when postback occurs, AsyncFileUpload loses the selected file and it is blank.
What can be done?
The employee information form has various fields including this.I have some dropdowns on the form which causes postback,
but when postback occurs, AsyncFileUpload loses the selected file and it is blank.
What can be done?
If you are using UpdatePanel in your page then you need to add the "Submit" button in Triggers to make it work
ASKER
Yes I am using Updatepanel.
Do you mean I should add triggers for all dropdowns and Save button?
Do you mean I should add triggers for all dropdowns and Save button?
If you are using the AsyncFileupload, no need to add a postback trigger ...
Working : The asyncfileupload is diff from other file upload control.... It does not require a postback .. The moment you select a file to the AsyncFileupload it starts uploading the file. the only thing you have to do is write an handler for the UploadedComplete ...
Just see this link
http://www.asp.net/%28S%28fu2l2uzphr2u3u45q2dnez55%29%29/ajax/AjaxControlToolkit/Samples/AsyncFileUpload/AsyncFileUpload.aspx
Working : The asyncfileupload is diff from other file upload control.... It does not require a postback .. The moment you select a file to the AsyncFileupload it starts uploading the file. the only thing you have to do is write an handler for the UploadedComplete ...
Just see this link
http://www.asp.net/%28S%28fu2l2uzphr2u3u45q2dnez55%29%29/ajax/AjaxControlToolkit/Samples/AsyncFileUpload/AsyncFileUpload.aspx
ASKER
I think you are talking abt this event.
protected void AsyncFileUpload1_UploadedC
AjaxControlToolkit.AsyncFi
{
if (AsyncFileUpload1.HasFile)
{
AsyncFileUpload1.SaveAs(Se
Path.GetFileName(e.filenam
}
}
--------------------------
well I am not uploading the file as soon as it is selected.
After selecting the image,user still needs to enter more details and then he will click on the Save button to save the form.
well I am not uploading the file as soon as it is selected -----------> you don't have to do that. it is built in to do that ... see this link
http://www.codeproject.com/KB/ajax/AsyncFileUpload.aspx ( see AsyncFileUpload Control Features -- disadvantages)
So as soon as the file is selected it will start upload asynchronously ... If you are having the code it will be saved ... Now since the file is uploaded you don't have to save it again while the user clicks save .. you can save all others but leave this one
http://www.codeproject.com/KB/ajax/AsyncFileUpload.aspx ( see AsyncFileUpload Control Features -- disadvantages)
So as soon as the file is selected it will start upload asynchronously ... If you are having the code it will be saved ... Now since the file is uploaded you don't have to save it again while the user clicks save .. you can save all others but leave this one
ASKER
Am I lost somewhere?
I am not using this event AsyncFileUpload1_UploadedC omplete
and On my Save Nutton CLick I am using AsyncFileUpload1.SaveAs to save the file.
After user selects the file and goes on with filling form,when he selects dropdown that causes postback,the selected file is lcleared from the control
I am not using this event AsyncFileUpload1_UploadedC
and On my Save Nutton CLick I am using AsyncFileUpload1.SaveAs to save the file.
After user selects the file and goes on with filling form,when he selects dropdown that causes postback,the selected file is lcleared from the control
You will need to use the event AsyncFileUpload1_UploadedC omplete .. I hope by now you must be convinced that file upload will start as soon as the user selects a file.
In the AsyncFileUpload1_UploadedC omplete you will need to save the file to the folder and get the filename/path to a viewstate or session
then finally when you are updating the DB just send the filename from the viewstate or session
NB: For the in between postbacks the selected file WILL be cleared from the control
In the AsyncFileUpload1_UploadedC
then finally when you are updating the DB just send the filename from the viewstate or session
NB: For the in between postbacks the selected file WILL be cleared from the control
ASKER
>>NB: For the in between postbacks the selected file WILL be cleared from the control
Can't I have the file still in the Upload control in between postback,as the user may be confused.
Further it may happen that,while saving form data there may be an error or user may leave the page.So in such cases still the image will be uploaded,which is not desired.
Can't I have the file still in the Upload control in between postback,as the user may be confused.
Further it may happen that,while saving form data there may be an error or user may leave the page.So in such cases still the image will be uploaded,which is not desired.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Thanks for the valuable help