Write FileUpload Path within an ASP.NET UpdatePanel

1

Expensive,

The question of my doubt is quite simple. How do I save the path of my FileUpload file to some control or ViewState, with that FileUpload being inside an UpdatePanel?

I am actually using the AsyncFileUpload AJAX control, since a simple FileUpload does not work with partial Post Back. No problem with that. So, I write the selected file on the page on my server, but at the same time I record it I need to use that same path (full path) to use it later, in a one-button event. I have tried to use ViewState, I have tried to change some properties of UpdatePanel, I have already tried to find a way to do this with JavaScript, but none of these features worked.

Would anyone know how to solve this problem?

Thank you in advance for your help.

Hugs!

    
asked by anonymous 16.05.2016 / 20:18

1 answer

0

After searching and searching, I finally managed to find the only solution. In fact it's even simple. I added a hidden (HiddenField) control on the page to record the information I want. There is an AsyncFileUpload event called OnUploadedComplete , where working within this event I just added a ScriptManager to save the value of the variable I wanted in that hidden control that I put on the page, simple as that. Now I can work this way I want, and honestly it seems to me the only way to do it. Anyway, if anyone knows another way to do it, please leave your comment, always welcome.

This would be the script:

ScriptManager.RegisterStartupScript(this, this.GetType(), "path", "top.$get('" + hfCaminhoArquivo.ClientID + "').value = '" + filePath + "';", true);

Here was where I found the answer:

    
17.05.2016 / 15:37