Event of button is not fired when i browse any file through fileupload control and upload it..connection time out error

谁说胖子不能爱 提交于 2019-12-12 06:48:59

问题


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

回答1:


please try after including this in your web.config file

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




回答2:


In aspx file:

<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>

In code behind:

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!";
}

You can also refer to this link:

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



来源:https://stackoverflow.com/questions/18078249/event-of-button-is-not-fired-when-i-browse-any-file-through-fileupload-control-a

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!