【问题标题】:UpdatePanel updating contents in other update panel while fileuploadUpdatePanel 在文件上传时更新其他更新面板中的内容
【发布时间】:2014-05-10 10:46:14
【问题描述】:

我有两个更新面板,都有更新模式作为条件,一个更新面板有文本框、下拉菜单、检查框等,另一个更新面板有文件上传,在文件上传时回发。 我的问题是,当我上传文件时,第一个更新面板中的所有内容也变为空或默认,但我希望内容保持为用户在更新之前设置的内容。

`<asp:UpdatePanel updatemode="conditional"..
 <Content.. 
<asp:TextBox ID="txtName" runat="server" Width="350px" Height="19px"></asp:TextBox>
<asp:DropDownList runat="server" ID="ddParent" DataSourceID="LDSParent">       
</asp:DropDownList>
<asp:LinqDataSource runat="server" ID="LDS" OnSelecting="LDS_Selecting">
</asp:LinqDataSource>
</Content..
</asp:UpdatePanel 
<asp:UpdatePanel updatemode="conditional"..
 <Content.. 
<asp:fileupload..
</Content..
</asp:UpdatePanel..`  

protected void LDS_Selecting(object sender, LinqDataSourceSelectEventArgs e)
    {  

        e.Result = (from p in table_name
                    select p);

    }

【问题讨论】:

  • 显示您在第一个 UpdatePanel 中初始化控件状态的代码
  • edited..state 只是从数据库中检索数据
  • 是不是通过魔术从数据库中检索到数据,或者您还有一些用于此目的的代码?如果是,请显示该代码。
  • 通过发布的代码,我只能建议仅在初始请求时绑定第一个 UpdatePanel 中的控件。如果您在Page_Load 方法中有Bind 方法调用,请将它们放在if(!IsPostback){} 块中

标签: c# asp.net file-upload updatepanel


【解决方案1】:

FileUpload 控件不适用于 UpdatePanel,因为它需要完整的回发。您不能异步调用文件上传控件。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2012-12-30
    • 1970-01-01
    • 2016-07-25
    • 2011-04-01
    • 1970-01-01
    • 1970-01-01
    • 2016-12-10
    • 1970-01-01
    相关资源
    最近更新 更多