How to use FileUpload in UpdatePanel?
I know that such question was has been many times already but I couldn't find any right solution for my problem.
I have MasterPage1 with ScriptManager. There is MasterPage2 in it. In 2-nd MasterPage I placed Control with UpdatePanel. In this UP I place开发者_StackOverflow中文版d FileUpload and SubmitButton:
Master1(with SM) <= Master2 <= Control(with FU and But)
I tried to debug method But_OnClick and saw that FU.PostedFile == null.
I tried to place PostBackTrigger to But in UP, I tried to do it from Control's code behind using something like Page.Master.Master.FindControl("ScriptManager") and it doesn't work.
And I even tried to use AjaxControlToolkit...
I solve this problem by myself!
First of all:
<form id="mainForm" runat="server" name="mainForm" enctype="multipart/form-data">
Then I use AjaxToolkitControl:
<ajax:AsyncFileUpload runat="server" ID="upload" OnUploadedComplete="UploadComplete" />
And In server event handler UploadComplete I can place the file-saving logic. Bingo!
You can't use a FileUpload asynchronously.
Have a look at this control which should do what you need.
精彩评论