The FileUpload control will not work inside an UpdatePanel control to upload files using the asynchronous postback. This is because file uploads and handling files are restricted by default on the client side for security reasons.
The file upload controls do not work in AJAX update panels . If your upload control located in an update panel , then the control does not send the file. If you look at the published property control file ( HasFile ), you see that is null.
To resolve this problem we have to rely on a standard data return, ie, we need to adjust the button up the file to be PostBack trigger. This will initiate a normal postback whenever we click on the upload button and then you can upload the file.
You must create a PostBackTrigger for the button that starts the postback as follows.
<Triggers>
<asp:PostBackTrigger ControlID="btnEnviar" runat="server" />
</Triggers>
For Example:<%@ Control Language="C#" AutoEventWireup="true" CodeBehind="Test.ascx.cs" Inherits="componentes.Test" %>
<%@ Register TagPrefix="asp" Namespace="AjaxControlToolkit" Assembly="AjaxControlToolkit" %>
Namespace="DevExpress.Web.ASPxFileManager" TagPrefix="dx" %>
<asp:UpdatePanel ID="UpdatePanel1" runat="server" UpdateMode="conditional">
<ContentTemplate>
<asp:Panel ID="panel1" runat="server" CssClass="zpglight" Height="229px">
<asp:Panel ID="panel3" runat="server" Style="z-index: 400" Height="150px">
<table width="645px">
<tr>
<td>
</td>
</tr>
<tr>
<td>
<asp:Label ID="Label3" runat="server" Text="Enviar o Arquivo:" BackColor="Silver"
Width="100%" Font-Bold="True" Height="16px"></asp:Label>
</td>
</tr>
</table>
<table width="645px">
<tr>
<td>
<asp:FileUpload ID="FileUpload1" runat="server" Width="100%" />
</td>
</tr>
</table>
<table width="645px">
<tr align="right">
<td>
<asp:ASPxButton ID="btnEnviar" runat="server" Text="Enviar" OnClick="btEnviar_Click">
</asp:ASPxButton>
</td>
</tr>
<tr>
<td>
<asp:Label ID="Label4" runat="server" Text="" Font-Bold="True" ForeColor="Red"></asp:Label>
</td>
</tr>
</table>
</asp:Panel>
</asp:Panel>
</ContentTemplate>
<Triggers>
<asp:PostBackTrigger ControlID="btnEnviar" runat="server" />
</Triggers>
</asp:UpdatePanel>
See also
Gracias ya estaba mas de 2 horas buscando la solucion, gracias por postear
ReplyDelete