【问题标题】:file upload inside update panel loses the file in asp.net更新面板内的文件上传会丢失 asp.net 中的文件
【发布时间】:2011-12-08 14:54:27
【问题描述】:

我在页面中有一个更新面板,每当从下拉框中选择一个值时,我都会在页面上显示一些文本,我已经为下拉设置了触发器,即使这样做之后页面也会在我返回更改下拉值,我哪里出错了

 <asp:UpdatePanel ID="UP_DDL" runat="server" UpdateMode="Conditional" ChildrenAsTriggers="true">
    <ContentTemplate>
          <asp:FileUpload ID="File_Audio" runat="server"  />
          <asp:DropDownList ID="ddl_SendAt" runat="server" AutoPostBack="true" 
                                            OnSelectedIndexChanged="ddl2_SelectedIndexChanged">
           <asp:ListItem Selected="True">Now</asp:ListItem>
           <asp:ListItem>After 1 Hour</asp:ListItem>
             </ContentTemplate>
      <Triggers>
          <asp:AsyncPostBackTrigger ControlID="ddl_SendAt" EventName="SelectedIndexChanged" />                                
      </Triggers>
 </asp:UpdatePanel>

我希望 DropDownList 进行回发以在文本框中显示内容,但我也有一个文件上传按钮。当我从计算机中选择一个文件并更改下拉列表时,会发生回发并且文件上传会丢失文件

【问题讨论】:

  • 文件上传控件是在updatepanel里面还是外面?
  • 它在更新面板中

标签: c# asp.net ajax updatepanel ajaxcontroltoolkit


【解决方案1】:

我基本上不推荐在 UpdatePanel 中使用 FileUpload 控件。文件上传通常需要完整的回发。

除非您在框架内实现文件上传。

【讨论】:

    【解决方案2】:

    检查您的ScriptManagerEnablePartialRendering 属性未设置为False,并将其删除或设置为True

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2011-04-01
      • 2023-03-14
      • 2015-02-17
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多