[CLOSED] file upload - file name is empty

  1. #1

    [CLOSED] file upload - file name is empty

    Hi,
    I have problems with file upload.

    After that I uploaded my file, my property filename is empty.

    My code (codebehind):

     protected void BtnImportar_Clique(object sender, DirectEventArgs e)
            {
                if (this.FileUploadDocumento.FileName != string.Empty)
                {
                    string nome = this.FileUploadDocumento.PostedFile.FileName;
                    int tamanho = this.FileUploadDocumento.PostedFile.ContentLength;
                    
                }
                else
                {
                    X.Msg.Show(new MessageBoxConfig
                    {
                        Buttons = MessageBox.Button.OK,
                        Icon = MessageBox.Icon.ERROR,
                        Title = "Atenção",
                        Message = "Selecione um arquivo."
                    });
                }
                
            }
    My code (.aspx):

    <%@ Page Language="C#" AutoEventWireup="true" CodeBehind="ImportarDocumento.aspx.cs" Inherits="Stoque.ECM.Web.Cliente.Forms.ImportarDocumento" %>
    
    <%@ Register Assembly="Ext.Net" Namespace="Ext.Net" TagPrefix="ext" %>
    
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head runat="server">
        <title></title>
    </head>
    <body> 
    
        <ext:ResourceManager ID="ResourceManagerImportarDocumento" runat="server" Theme="APFiscalVerde" > </ext:ResourceManager>
    
         <ext:Store ID="StoreTipoDocumentoID" runat="server" AutoLoad="true" >        
            <Reader>                                                        
                <ext:JsonReader IDProperty="id" >
                    <Fields>
                        <ext:RecordField Name="id"  />
                        <ext:RecordField Name="nome"  />                                                                                                 
                    </Fields>
                </ext:JsonReader>            
            </Reader>                                  
        </ext:Store> 
    
        <ext:FormPanel ID="FormPnlImportarDocumentoID" runat="server" ButtonAlign="Right" Layout="absolute" Width="280" Height="580">
            <Items>
                <ext:Label ID="lblCaminho" runat="server"  Text="Caminho:" Width="100" X="10" Y="10" />
                <ext:FileUploadField ID="FileUploadDocumento"                                
                                    runat="server"
                                    Width="240" X="10" Y="30" 
                                    Icon="Attach" />
                <ext:Label ID="LblTipoDocumentoID" runat="server" Text="Tipo Documento:" LabelAlign="Top"  Width="240" X="10" Y="60" />
                <ext:ComboBox ID="CbxTipoDocumentoID"                        
                            runat="server" X="10" Y="80"                        
                            LabelAlign="Top" 
                            TypeAhead="true"
                            LoadingText = "Carregando ..." 
                            ForceSelection="true"                                                                                                                
                            DisplayField="nome"                                                          
                            ValueField="id"
                            TriggerAction="All" 
                            SelectOnFocus="true"
                            StoreID="StoreTipoDocumentoID"
                            EmptyText="... Selecione ... "
                            Width="240"> 
                            <DirectEvents>
                            <Select OnEvent ="CbxTipoDocumento_Clique">
                                <EventMask ShowMask="true" Msg="Aguarde ..." MinDelay="500" />
                            </Select>                                                        
                        </DirectEvents>   
                </ext:ComboBox>
                
                <ext:Panel 
                        ID="PanelComponenteDinamicoID" 
                        runat="server"                                                        
                        Width="260" Height="300" 
                        Closable="false"                                                        
                        Layout="absolute" 
                        X="10" Y="170" 
                        Border="false"                                                        
                        >  
                </ext:Panel> 
    
                <ext:Checkbox ID="CbxIniciarFluxo" runat="server" X="10" Y="110"></ext:Checkbox>
                <ext:Label ID="LblIniciarFluxo" runat="server" Text="Iniciar Fluxo" X="35" Y="110"> </ext:Label>
                <ext:Checkbox ID="CbxArquivar" runat="server" X="10" Y="150"></ext:Checkbox>
                <ext:Label ID="LblArquivar" runat="server" Text="Arquivar" X="35" Y="150"></ext:Label>
            </Items>
            <Buttons>
                <ext:ImageButton ID="BtnImportar" runat="server" ImageUrl="../Resources/images/botaobuscar.gif"> 
                  <DirectEvents>
                            <Click 
                                OnEvent="BtnImportar_Clique"
                                Before="if (!#{FormPnlImportarDocumentoID}.getForm().isValid()) { return false; } 
                                    Ext.Msg.wait('Aguarde ...');"
                                    
                                Failure="Ext.Msg.show({ 
                                    title   : 'Erro', 
                                    msg     : 'Erro durante a inserção.', 
                                    minWidth: 200, 
                                    modal   : true, 
                                    icon    : Ext.Msg.ERROR, 
                                    buttons : Ext.Msg.OK 
                                });">
                            </Click>
                        </DirectEvents>
                </ext:ImageButton>
            </Buttons>
        </ext:FormPanel>
       
    </body>
    </html>
    In method BtnImportar_Clique, this.FileUploadDocumento.FileName is empty.

    Any suggestion?

    Thanks!
    Last edited by Daniil; May 11, 2011 at 8:31 PM. Reason: [CLOSED]
  2. #2
    Hi,

    Please add ASP.NET form (form with runat="server" attribute)
  3. #3
    Very cool Vladimir,

    Thanks. Please mark as solved.

Similar Threads

  1. [CLOSED] multiple file upload and file size at client side
    By mirwais in forum 1.x Legacy Premium Help
    Replies: 24
    Last Post: Dec 15, 2014, 5:44 AM
  2. Replies: 1
    Last Post: Jun 23, 2011, 9:37 AM
  3. Upload file
    By Egale in forum 1.x Help
    Replies: 1
    Last Post: May 25, 2011, 10:08 AM
  4. [CLOSED] Help with file upload
    By smart+ in forum 1.x Legacy Premium Help
    Replies: 5
    Last Post: Sep 09, 2010, 8:02 PM
  5. [CLOSED] Upload File
    By Casbah in forum 1.x Help
    Replies: 5
    Last Post: Nov 18, 2008, 12:30 PM

Tags for this Thread

Posting Permissions