2012-11-23 46 views
1

我想上傳文件到服務器與EXT.NET 2.0版我試圖上傳文件服務器使用的EXT.NET 2.0

在我的情況幫助: 我是下

<ext:FileUploadField ID="FileUploadField1" runat="server" Width="300"><DirectEvents> 


</DirectEvents></ext:FileUploadField> 

給我錯誤的<FileSelected OnEvent="FileUploadField_FileSelected" IsUpload="true" /> FileSelected不可

我的代碼:

<%@ Page Language="C#" %> 

<%@ 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>Ext.NET Example</title> 
</head> 
<body> 
    <form runat="server"> 
     <ext:ResourceManager runat="server" /> 
     <ext:FileUploadField ID="FileUploadField1" runat="server" Width="300"> 
      <DirectEvents> 
       <FileSelected OnEvent="FileUploadField_FileSelected" IsUpload="true" /> 
      </DirectEvents> 
     </ext:FileUploadField> 
    </form> 
</body> 
</html> 

我的C#代碼: 在此另存爲選項是無效的生成錯誤:

protected void FileUploadField_FileSelected(object sender, DirectEventArgs e) 
    { 
     this.FileUploadField1.SaveAs(@"D:\video1.mp4"); 
    } 

回答

4

試試這個:

<%@ Page Language="C#" %> 

<%@ Register Assembly="Ext.Net" Namespace="Ext.Net" TagPrefix="ext" %> 
<script runat="server"> 
    protected void FileUploadField_FileSelected(object sender, DirectEventArgs e) { 
     if (this.FileUploadField1.HasFile) 
     { 
      HttpPostedFile file = FileUploadField1.PostedFile; 
      file.SaveAs(@"d:\" + file.FileName); 
     } 
    } 
</script> 
<!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>Ext.NET Example</title> 
</head> 
<body> 
    <form runat="server"> 
     <ext:ResourceManager runat="server" SourceFormatting="True" ScriptMode="Debug" /> 
     <ext:FileUploadField ID="FileUploadField1" runat="server" Width="300"> 
      <DirectEvents> 
       <Change OnEvent="FileUploadField_FileSelected" IsUpload="true"></Change> 
      </DirectEvents> 
     </ext:FileUploadField> 
    </form> 
</body> 
</html> 
+0

感謝名單@Daulet Urazalinov –

相關問題