when page refresh happen Fileupload control get cleared.
-
Hi, I am using fileupload control in asp.net. am selecting the file using browse button of file upload control. But due to postback event of any other control on the page the content(file path) of the fileupload textbox gets cleared... Viewstate is enabled to this control. How to solve this problem??? am using vs 2008 and c#...
-
Hi, I am using fileupload control in asp.net. am selecting the file using browse button of file upload control. But due to postback event of any other control on the page the content(file path) of the fileupload textbox gets cleared... Viewstate is enabled to this control. How to solve this problem??? am using vs 2008 and c#...
I believe that is default behaviour. You can retain the text through doing partial postback using update panel. Do not send upload control while doing the postback and it should retian the value.
50-50-90 rule: Anytime I have a 50-50 chance of getting something right, there's a 90% probability I'll get it wrong...!!
-
I believe that is default behaviour. You can retain the text through doing partial postback using update panel. Do not send upload control while doing the postback and it should retian the value.
50-50-90 rule: Anytime I have a 50-50 chance of getting something right, there's a 90% probability I'll get it wrong...!!
-
I tried like this but not working. Just I placed scriptmanager and updatepanel on the page and kept the fileupload control inside updatepanel... Have I followed correctly???
Wait a minute, were you referring to postback caused by clicking upload button or some other control? If you mean after clicking on upload button, I guess it is not possible. Also, AFAIK, you cannot set the text of te textbox in the control so you cannot even keep the file path somewhere and just set it. If you were referring to some other control which is causing postback, then keep just that control in the update panel and not the upload control.
50-50-90 rule: Anytime I have a 50-50 chance of getting something right, there's a 90% probability I'll get it wrong...!!
-
Hi, I am using fileupload control in asp.net. am selecting the file using browse button of file upload control. But due to postback event of any other control on the page the content(file path) of the fileupload textbox gets cleared... Viewstate is enabled to this control. How to solve this problem??? am using vs 2008 and c#...
Well... Html file control is very restrictive control. You cannot set value of file upload using javascript. You can only set using Browse Button. Now when the page is posted back, the whole page is sent to the server, server processes it and rewrites the whole page to the response and which is written over the browser(client). Thus if you select a file and some other button makes the postback, dont hesitate to save the file to the server as, the path, if not saved to the server, cant be shown in the file control at any case. Otherwise you can show a popup (preferably using window.open) to upload files and do the upload immediately after user selects the file. :rose:
Abhishek Sur **Don't forget to click "Good Answer" if you like this Solution.
My Latest Articles-->** Simplify Code Using NDepend
Basics of Bing Search API using .NET
Microsoft Bing MAP using Javascript -
Well... Html file control is very restrictive control. You cannot set value of file upload using javascript. You can only set using Browse Button. Now when the page is posted back, the whole page is sent to the server, server processes it and rewrites the whole page to the response and which is written over the browser(client). Thus if you select a file and some other button makes the postback, dont hesitate to save the file to the server as, the path, if not saved to the server, cant be shown in the file control at any case. Otherwise you can show a popup (preferably using window.open) to upload files and do the upload immediately after user selects the file. :rose:
Abhishek Sur **Don't forget to click "Good Answer" if you like this Solution.
My Latest Articles-->** Simplify Code Using NDepend
Basics of Bing Search API using .NET
Microsoft Bing MAP using JavascriptHow to save and assign to the fileupload control? am trying to assign the path like this FileUpload1.PostedFile.FileName = "Path"; but getting error "Property or indexer 'System.Web.UI.WebControls.FileUpload.FileName' cannot be assigned to -- it is read only. any idea??
-
How to save and assign to the fileupload control? am trying to assign the path like this FileUpload1.PostedFile.FileName = "Path"; but getting error "Property or indexer 'System.Web.UI.WebControls.FileUpload.FileName' cannot be assigned to -- it is read only. any idea??
-
save path in any string/contol... for label control...
label.text=File1.PostedFile.FileName;
-
but how to assign string value to fileupload control... I tried but got error messages... pls see my previous post...
You cannot as I told you. Fileupload should be the last thing to do in a page. Or else, have a listbox/listview (in case of multiple file upload) or a label with remove button or something in your page. That should work. Something like what we get in Gmail or outlook.
50-50-90 rule: Anytime I have a 50-50 chance of getting something right, there's a 90% probability I'll get it wrong...!!
-
How to save and assign to the fileupload control? am trying to assign the path like this FileUpload1.PostedFile.FileName = "Path"; but getting error "Property or indexer 'System.Web.UI.WebControls.FileUpload.FileName' cannot be assigned to -- it is read only. any idea??
You cant do that ... Even ASP.NET cant do this, thus it cant retain its value during postbacks.. Sorry.. You need to store it in server as soon as you find it in server. And then show the message, file uploaded successfully.. .or so... ;)
Abhishek Sur **Don't forget to click "Good Answer" if you like this Solution.
My Latest Articles-->** Simplify Code Using NDepend
Basics of Bing Search API using .NET
Microsoft Bing MAP using Javascript -
You cant do that ... Even ASP.NET cant do this, thus it cant retain its value during postbacks.. Sorry.. You need to store it in server as soon as you find it in server. And then show the message, file uploaded successfully.. .or so... ;)
Abhishek Sur **Don't forget to click "Good Answer" if you like this Solution.
My Latest Articles-->** Simplify Code Using NDepend
Basics of Bing Search API using .NET
Microsoft Bing MAP using Javascript -
still confusing.. How to store(session or any string variable) and assign to to fileupload control...
As I already told you, even if you set the value of a FileUpload control, it cant assign the appropriate file pointer to the browser. So dont try to do this, rather when user choose the file, upload to the server immediately and work from the file placed in the server. Cheers. :rose:
Abhishek Sur **Don't forget to click "Good Answer" if you like this Solution.
My Latest Articles-->** Simplify Code Using NDepend
Basics of Bing Search API using .NET
Microsoft Bing MAP using Javascript