0

I have to verify if the UploadFile control of asp.net 4.5 .NET Framework like this:

<asp:FileUpload runat="server" AllowMultiple="true"/>

can be use with Ajax without Ajax Toolkit File Upload for uploading multiple files.

I have seen those threads :

but they are too old for my needs and they havn't give me answers.

The person who worked on the project before me said that he had a problem with this control in a previous version and he was forced to use Ajax Toolkit File Upload.

Thank you in advance.

Vincino
  • 66
  • 9

1 Answers1

0

I have found something that is the beginning of an answer.

Using an Ajax's UpdatePanel like this:

<asp:ScriptManager ID="ToolkitScriptManager1" runat="Server" />
<asp:UpdatePanel ID="UpdatePanel1" runat="server" UpdateMode="Conditional">
   <ContentTemplate>
        <asp:FileUpload ID="fileUpload1" runat="server" AllowMultiple="true"/>
        <asp:Button ID="btnDoSomething" runat="server" Text="Do something" />
    </ContentTemplate>

    <Triggers>
        //Prevents postback and refresh of the page.
        <asp:AsyncPostBackTrigger ControlID="btnDoSomething" />
    </Triggers>        
</asp:UpdatePanel>

But, you can't properly upload files without a post back. For that, we have to add another button which will trigger the postback:

<asp:Button ID="btnUpload" runat="server" Text="Upload" />

And by adding it to <Triggers> tag:

<Triggers>
    <asp:AsyncPostBackTrigger ControlID="btnDoSomething" /> //Without post back
    <asp:PostBackTrigger ControlID="btnUpload" />  //With post back
</Triggers>
Vincino
  • 66
  • 9