Write Fileupload Path inside an ASP.NET Updatepanel

Asked

Viewed 315 times

4

Expensive,

The question of my doubt is very simple. How do I save the path of my Fileupload file to some control or Viewstate, with this Fileupload being inside an Updatepanel?

I’m actually using Asyncfileupload’s AJAX control, since a simple Fileupload doesn’t 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 write I need to use that same path (full path) to use it later, in a one button event. I have tried using Viewstate, I have tried to change some properties of Updatepanel, I have tried to find a way to do this with Javascript, but none of these features has any effect.

Would anyone know how to solve this problem?

Thank you in advance for your help.

Hugs!

  • In case I have solved your problem, mark as answer.

2 answers

0

After searches and searches, finally I managed to find the only solution. In fact it is even simple. I added an Hidden (Hiddenfield) type control to the page to record the information I want. There’s an Asyncfileupload event called OnUploadedComplete, where working within that event I just added a ScriptManager to record the value of the variable I wanted in this Hidden control I put on the page, simple like this. Now I can work the way I want to, and honestly it seems the only way to do that. Anyway, if anyone knows any other way of doing, please leave your comment, it is always welcome.

This would be the script:

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

Here that’s where I found the answer:

0

With panel also could not, and using hiddenfield here worked! See if the example is useful. At the end will be the name and extension:

string fileName;
 if (fuArquivo01.HasFile)
 {
  fileName = null;
  fileName = fuArquivo01.FileName;
  fileName += System.IO.Path.GetExtension(fuArquivo01.FileName).ToLower();
  HiddenField1.value = fileName;
 }
  • In case I have solved your problem, mark as answer.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.