2013-08-06 26 views
-1
 
Hi, 
I have file upload control and upload button in my application 

    asp:FileUpload ID="FileUpload1" runat="server" Width="250px" /> 

    asp:Button runat="server" ID="btn_upload" Text="Upload" 
onclick="btn_upload_Click" 

i have included it in .aspx file 
when i browse any file using this control and click on upload button 
i got the connection timeout error. 
.this case is only with fileupload control,but if i dint browse any file and click on upload button then this error is not coming, 
click event of upload button(btn_upload_Click) gets fired but with Fileupload control after browsing any file click event of upload button not firing. 
.why this problem occurs..plz help 
+0

解決了沒有? –

+0

感謝您的答案..實際上,這個問題是因爲瀏覽器問題 – shweta

回答

0

請包括這在你的web.config文件後,儘量不解僱

<system.web> <httpRuntime executionTimeout="999999" maxRequestLength="2097151" /> </system.web>

0

在aspx文件:

<asp:FileUpload ID="FileUpload1" runat="server" /> 
     <asp:Button ID="Button1" runat="server" Text="Upload" 
      onclick="Button1_Click" /> 
      <asp:Label ID="Label1" runat="server" Text="Label"></asp:Label> 

在後面的代碼:

protected void Button1_Click(object sender, EventArgs e) 
{ 
    string filename = Path.GetFileName(FileUpload1.FileName); 
    FileUpload1.SaveAs(Server.MapPath("~/") + filename); 
    Label1.Text = "Upload status: File uploaded!"; 
} 

您也可以參考此鏈接:

http://asp.net-tutorials.com/controls/file-upload-control/

相關問題