带有postbacktrigger的Fileupload导致页面刷新 [英] Fileupload with postbacktrigger causing page refresh

查看:121
本文介绍了带有postbacktrigger的Fileupload导致页面刷新的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在执行文件上传,它具有不同的控件,例如更新面板中的下拉列表和单选按钮.

发生回发时,将导致文件上传丢失内容.因此,我将PostbackTrigger用于所有相关控件.

该解决方案有效,但是导致另一个问题,当下拉列表selectedIndexChanged时,整个页面将被刷新.

有人有解决这个问题的想法吗?

预先感谢您的帮助.

我尝试过的事情:

我尝试使用AsynPostbackTrigger并将ChildrenAsTrigger = True.但是,此方法无济于事,并且页面仍在刷新.除此之外,我不确定哪种解决方案可以应用,因为我已经通过Internet搜索并且找不到类似的问题.

I am doing a file upload which having different control like Drop down list and Radio button inside a update panel.

When there is a postback, it will causing the file upload lose content. Hence, I put the PostbackTrigger for all the related controls.

The solution was worked, but causing another issue where the whole page being refreshed when drop down list selectedIndexChanged.

Do anyone have ideas to solve this problem?

Thanks in advance for the help.

What I have tried:

I have tried to use AsynPostbackTrigger and putting the ChildrenAsTrigger = True. But, this method not able to help and the page still refreshing. Apart from this, I am not sure what kind of solution can apply as I have search through internet and not able to find the similar problem.

推荐答案

FileUpload控件没有不能在异步更新面板中使用.选择文件后,如果执行某些操作以发布更新面板的更新,则该文件将丢失其值,因为出于安全原因您无法预先选择该文件.

您可能需要重新架构您正在做的工作,并将该过程分为两个步骤...第一步,收集文件中的内容,然后第二步,请他们上载文件.要么使用asych文件上传插件,要么可以异步上传文件,因为updatepanel方法将无法正常工作.
The FileUpload control doesn''t work inside an asynch updatepanel. When you have selected a file and then do something that issues an update of the update panel the file will lose its value as you can''t pre-select that for security reasons.

You''re probably going to have to re-architect what you''re doing and split the process into two steps...gather the things apart from the file in the first step, then on the second step ask them to upload the file. Either that or use an asych file upload plug in that will allow you to upload the file asynchronously, as the updatepanel method isn''t going to work.


对于这种类型的问题,没有需要使用AsynPostbackTrigger.
只需将下拉控件放在UpdatePanel控件(即ajax控件)中即可.

For this type of problem, no need to use AsynPostbackTrigger.
Just put your dropdown controls in UpdatePanel control i.e. ajax control.

<asp:UpdatePanel ID="UpdatePanel1" runat="server">
    <ContentTemplate>
        <asp:DropDownList runat="server" ID="ddlLink">
            <asp:ListItem Text="text1" />
            <asp:ListItem Text="text2" />
        </asp:DropDownList>
    </ContentTemplate>
</asp:UpdatePanel>





如果您在页面加载时完成了任何代码,即要在页面加载时加载一次,请将这些行放在





if you have done any code on page load i.e. to load once on page load, put those lines in

protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            //Lines of code
        }
    }


这篇关于带有postbacktrigger的Fileupload导致页面刷新的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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