当我通过文件上传控件浏览任何文件并将其上传时,按钮事件未触发.连接超时错误 [英] Event of button is not fired when i browse any file through fileupload control and upload it..connection time out error

查看:72
本文介绍了当我通过文件上传控件浏览任何文件并将其上传时,按钮事件未触发.连接超时错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述


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

推荐答案

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

这篇关于当我通过文件上传控件浏览任何文件并将其上传时,按钮事件未触发.连接超时错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆