May 11, 2011, 7:13 PM
[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):
Any suggestion?
Thanks!
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]