none
How to use FileUpload with UpdatePanel. RRS feed

  • Pregunta

  • Hello,

    I'm trying to use a control "asp: UpdatePanel" to display a GIF when performed an action.

    The GIF should be appear after click a control "asp: Button."

    Before pressing the button, in client side select a file that I uploaded to the server, use this control "asp: FileUpload. When not using the control "asp: UpdatePanel" the file of which I speak was loaded correctly, but I have inserted the code does not. While it appears GIF, does not load the file i need and I can not perform the action that speak.

    The steps are:

    1. Select File: This is good.

    1.1. The file is loaded: do not get to do.

    2. Click the button: It is good.

    2.1 Painting the GIF: This is good.

    2.2 Starting the process: It is good, but as there is no file loaded does not perform the action that you request. Without UpdatePanel works. To display the code, I have the following ASPX markup:

     

     

    <asp:ScriptManager ID="ScriptManager1" runat="server" >
    </asp:ScriptManager>
    <asp:UpdateProgress ID="UpdateProg1" DisplayAfter="10" runat="server" AssociatedUpdatePanelID="updatepanel1"> 
     <ProgressTemplate> 
     <div style="position: relative; top: 30%; text-align: center;"> 
      <img src="../img/load2.gif" style="vertical-align:middle" alt="Procesando"/> 
      Procesando ... 
     </div> 
     </ProgressTemplate> 
    </asp:UpdateProgress>
    <asp:UpdatePanel ID="updatepanel1" runat="server">
     <Triggers></Triggers>
     <ContentTemplate> 
      <%--<asp:Panel ID="PagesPanel" runat="server" > --%>    
        <div class="ADMaccountInfo">
         <span class="failureNotification">
          <asp:Literal ID="FailureText" runat="server"></asp:Literal>
         </span>
         <span class="successNotification">
          <asp:Literal ID="SuccessText" runat="server"></asp:Literal>
         </span> 
         <asp:ValidationSummary ID="ValidationSummary" runat="server" CssClass="failureNotification" 
          ValidationGroup="ValidationGroup"/>
         <fieldset class="ADMlogin">
          <legend id="legend" runat="server">Importar Fichero</legend>
           <div id="FileUp" runat="server" class="ADMaccountInfo">
            <p class="Parrafo">&nbsp;&nbsp;&nbsp;&nbsp;
             <asp:FileUpload ID="FileUpload1" runat="server" OnDataBinding="FileUpload_OnDataBinding"/>&nbsp;&nbsp;&nbsp;&nbsp;<label id="labelExtensiones" class="lbltextEntry"> Adjuntar archivo .unl, .txt ó .xml <img 
              src="../img/i.jpg" alt="Ayuda" onclick="javascript:window.open('FormatoFicheros.aspx')" 
              style="height: 15px; width: 15px" /></label>
              <br /><br />
             <label id="lblFile" runat="server" class="lbltextEntry"></label>
            </p>
            <p class="Parrafo">&nbsp;&nbsp;&nbsp;&nbsp;            
             <asp:Button ID="BtnSelec" runat="server" ValidationGroup="ValidationGroup"
             CommandName="BtnSelec" Text="Importar" CssClass="ADMsubmitButton" Visible="true"/>                      
             &nbsp;&nbsp;&nbsp;&nbsp;
             <asp:Button ID="ButtonDescargar" runat="server"
             CommandName="ButtonDescargar" Text="Descargar" CssClass="ADMsubmitButton" Visible="false"/>          
            </p>
            <p class="Parrafo">
             <label id="labelNota" class="lbltextEntry">Nota: La importación de empleados en el sistema puede tardar varios minutos. 
             <br /> Espere hasta que el sistema procese la información al completo.</label>
            </p>
            <asp:RequiredFieldValidator 
             id="RequiredFieldValidator1" runat="server" 
             ErrorMessage="Necesita seleccionar un archivo" 
             ControlToValidate="FileUpload1"
             ValidationGroup="ValidationGroup"
             cssclass="failureNotification">*
            </asp:RequiredFieldValidator>
           </div>              
         </fieldset>
        </div> 
      <%--</asp:Panel>--%>        
     </ContentTemplate>
    </asp:UpdatePanel>
    

    I Tried uncommenting the control "asp:panel".

    Thanks.


    Regards, Pablo Martín Gutierrez.
    lunes, 6 de junio de 2011 12:35

Respuestas

  • you should use

    AsyncFileUpload

    it is a ajax control to upload files

     

    saludos


    Leandro Tuttini

    Blog
    Buenos Aires
    Argentina
    • Marcado como respuesta Blonix lunes, 6 de junio de 2011 15:48
    lunes, 6 de junio de 2011 13:00
  • Fixed: Debugging the code I could see that the event "OnUploadedComplete" in the "AsyncFileUpload_UploadedComplete yes that file was loaded correctly (Me.FileUpload1.HasFile = True). So that the file is not lost I had to establish ownership PersistFile = "true" within control "AjaxToolkit: AsyncFileUpload."
    Regards, Pablo Martín Gutierrez.
    • Marcado como respuesta Blonix lunes, 6 de junio de 2011 15:49
    lunes, 6 de junio de 2011 15:48

Todas las respuestas

  • you should use

    AsyncFileUpload

    it is a ajax control to upload files

     

    saludos


    Leandro Tuttini

    Blog
    Buenos Aires
    Argentina
    • Marcado como respuesta Blonix lunes, 6 de junio de 2011 15:48
    lunes, 6 de junio de 2011 13:00
  • Hi,

    I tried to use the control that i've listed but still not working.

    I replaced the line of the control "asp:FileUpload" by the following:

    <asp:AsyncFileUpload ID="FileUpload1" runat="server" UploadingBackColor="#CCFFFF" ThrobberID="Mythrobber" />

    But still not load the file, ie within the VB file I have the following code block:

    Then if Me.FileUpload1.HasFile
    ...
    Else
    ...

    End If

     

    Always appears in the Else área, the file is nor loaded.

    The changes are shown as "textbox" color from light bue (#CCFFFF) to green before i clicked the button.

    Do I need do more?


    Regards, Pablo Martín Gutierrez.
    lunes, 6 de junio de 2011 14:59
  • I have used the tag "asp:" because by using "AjaxToolkit:" I do not compile the code.
    when dragged from the toolbox cotrol generates the tag "asp:".

     

    I have also tried to change the "TagPrefix"with "AjaxToolkit" and used for the control"AsyncfileUpload" but gives the same result.

    I've tried has included the event "OnUploadedComplete ="AsyncFileUpload_UploadedComplete "and making a break point in"AsyncFileUpload_UploadedComplete "I see coming, but it does not load the file.


    Regards, Pablo Martín Gutierrez.
    lunes, 6 de junio de 2011 15:13
  • Fixed: Debugging the code I could see that the event "OnUploadedComplete" in the "AsyncFileUpload_UploadedComplete yes that file was loaded correctly (Me.FileUpload1.HasFile = True). So that the file is not lost I had to establish ownership PersistFile = "true" within control "AjaxToolkit: AsyncFileUpload."
    Regards, Pablo Martín Gutierrez.
    • Marcado como respuesta Blonix lunes, 6 de junio de 2011 15:49
    lunes, 6 de junio de 2011 15:48