UpdatePanel 中的 ASP.NET FileUpload - 仍然无法正常工作 [英] ASP.NET FileUpload in UpdatePanel - still not working

查看:13
本文介绍了UpdatePanel 中的 ASP.NET FileUpload - 仍然无法正常工作的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

尝试在 NET 4.5/C# 网络应用程序的更新面板中使用 FileUpload 或 AsyncFileUpload 控件.

Attempting to use a FileUpload or AsyncFileUpload control in an updatepanel on a NET 4.5/C# web application.

我已经尝试在我的母版页中使用标准 Scriptmanager 或 ToolKitScriptManager.

I've tried using either standard Scriptmanager or ToolKitScriptManager in my masterpage.

我的保存按钮设置为 PostBackTrigger(也尝试过 AsyncPostbackTrigger).

My Save button is set as a PostBackTrigger (tried AsyncPostbackTrigger too).

无论如何,我的 (Async)FileUpload.HasFile 总是返回 false.

No matter what, my (Async)FileUpload.HasFile always returns false.

删除更新面板,两个上传控件都可以正常工作.

Remove the updatepanel and both uploadcontrols work fine.

真正让我感到震惊的是,我在另一个项目中使用了它(母版中的脚本管理器,更新面板中的 Fileupload,SaveButton 是 PostbackTrigger).

What really throws me is that I have this working in another project (scriptmanager in masterpage, Fileupload in updatepanel, SaveButton is PostbackTrigger).

是否有某些特定的 AJAX 版本或 .NET 版本会导致问题?

Is there some specific AJAX version or .NET version that can cause problems?

这非常令人沮丧.

推荐答案

将按钮添加到 UpdatePanel 的触发器标签,我让它工作了:

Adding the button to the UpdatePanel's trigger tag, I got it working:

<asp:UpdatePanel ID="UpdatePanel" runat="server">
    <ContentTemplate>
        <asp:FileUpload ID="FileUpload" runat="server" />
        <asp:Button ID="btnUpload" runat="server" Text="Upload"
           OnClick = "btnUpLoad_OnClick" />               
    </ContentTemplate>
    <Triggers>
        <asp:PostBackTrigger ControlID = "btnUpload" />
    </Triggers>
</asp:UpdatePanel>

我不必在服务器端做任何不同的事情(比如 user5159158 的回答).

I did not have to do anything different server-side (like user5159158's answer).

这篇关于UpdatePanel 中的 ASP.NET FileUpload - 仍然无法正常工作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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