Attempting to use a FileUpload or AsyncFileUpload control in an updatepanel on a NET 4.5/C# web application.
I've tried using either standard Scriptmanager or ToolKitScriptManager in my masterpage.
My Save button is set as a PostBackTrigger (tried AsyncPostbackTrigger too).
No matter what, my (Async)FileUpload.HasFile always returns false.
Remove the updatepanel and both uploadcontrols work fine.
What really throws me is that I have this working in another project (scriptmanager in masterpage, Fileupload in updatepanel, SaveButton is PostbackTrigger).
Is there some specific AJAX version or .NET version that can cause problems?
This is extremely frustrating.
Adding the button to the UpdatePanel's trigger tag, I got it working:
<asp:UpdatePanel ID="UpdatePanel" runat="server">
<ContentTemplate>
<asp:FileUpload ID="FileUpload" runat="server" />
<asp:Button ID="btnUpload" runat="server" Text="Upload"
OnClick = "btnUpLoad_OnClick" />
</ContentTemplate>
<Triggers>
<asp:PostBackTrigger ControlID = "btnUpload" />
</Triggers>
</asp:UpdatePanel>
I did not have to do anything different server-side (like user5159158's answer).
In Page_Load add: Page.Form.Attributes.Add("enctype", "multipart/form-data");
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With