上传文件中的UpdatePanel不工作 [英] upload file not working in updatepanel

查看:126
本文介绍了上传文件中的UpdatePanel不工作的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我不想让我的网页上,GET刷新或回发

I DONT WANNA GET MY PAGE TO BE GET REFRESH OR POSTBACK

所以我想上传文件中的UpdatePanel但onclicking上传按钮验证检查表明,没有文件

So I am trying uploading file in updatepanel but onclicking upload button the validation check shows that there is no file

我的html code是

my html code is

<asp:UpdatePanel ID="UpdatePanel16" runat="server" UpdateMode="Conditional">
<ContentTemplate>
 <asp:FileUpload ID="fp_upload" runat="server" />&nbsp;&nbsp;
<asp:Button ID="btn_browse" runat="server" Text="Upload" OnClick="btn_browse_Click" />
   </ContentTemplate>  
</asp:UpdatePanel>

这似乎是

我的.cs code是

my .cs code is

protected void btn_browse_Click(object sender, EventArgs e)
{
   if (fp_upload.HasFile)
    {
        Response.Write("contains file");
    }
    else
    {
       Response.Write("no file");
    }
}

当我用浏览文件,然后点击上传按钮每个时代它会在其他条件。什么问题。

when I used to browse the file and click on upload button every times it goes in else condition. Whats the problem.

同时我不想让我的网页上,GET刷新或回发

ALSO I DONT WANNA GET MY PAGE TO BE GET REFRESH OR POSTBACK

推荐答案

要使用UpdatePanel控件内的FileUpload控件,设置提交的文件是为面板PostBackTrigger控制回发的控制。

To use a FileUpload control inside an UpdatePanel control, set the postback control that submits the file to be a PostBackTrigger control for the panel.

这篇关于上传文件中的UpdatePanel不工作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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