asp.net的UpdatePanel PostBackTrigger触发完全回发 [英] asp.net updatePanel PostBackTrigger triggering full postback

查看:1347
本文介绍了asp.net的UpdatePanel PostBackTrigger触发完全回发的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

下面是标记页

  <asp:UpdatePanel runat="server" UpdateMode="Conditional">
        <ContentTemplate>
                    <table>
                        <tr>
                            <td>
                                <label>File name<label>
                            </td>
                        </tr>
                       <tr>
                            <td>
  <asp:TextBox runat="server" ID="txtName" Width="150%"></asp:TextBox>
                            </td>
                        </tr>
                      <tr>
                            <td>
                                <label>File</label>
                            </td>
                            <td>
                                <asp:FileUpload runat="server" ID="fileUpload" />
                            </td>
                        </tr>
                    </table>
                    <asp:Button runat="server" ID="btnUpload" Text="Upload file"  OnClick="btnUpload_Click" />
                </div>

                <div class="panel-heading">File display</div>
                <div class="panel-body">
     <asp:GridView runat="server">
       </asp:GridView>
                    <asp:Button runat="server" ID="btnRefresh" Text="Refresh" OnClick="btnRefresh_Click" />
                </div>
            </div>
        </ContentTemplate>
        <Triggers>
            <asp:PostBackTrigger ControlID="btnUpload" />
        </Triggers>
    </asp:UpdatePanel>

通过上面的code,当用户点击btnUpload,就会有一个回,但有一个更新面板以prevent后回来,当我改变了PostBackTrigger到AsyncPostBackTrigger,该页面没有张贴回,但fileUpload.HasFile将是错误的,是无法获得该文件。

With the above code, whenever the user clicks "btnUpload", there'll be a post back, but there is an update panel to prevent the post back, when I change the PostBackTrigger to AsyncPostBackTrigger, the page didn't post back but the fileUpload.HasFile will be false and was unable to get the file.

这有什么错上述code?为什么postBackTrigger触发回发?

What's wrong with the above code?Why the postBackTrigger triggers a post back?

推荐答案

文件上传将不会与AsyncPostBackTrigger 工作。它只会与PostBackTrigger工作。结果
解决方案:如果您要上传与AsyncPostBackTrigger文件比你必须使用ajaxtoolkit。而在AjacToolkit他们是控制名称以AsyncFileUpload。结果
希望你知道如何AjaxToolkit添加到您的工具箱。如果你不知道比告诉我,我会引导你。

File upload will not work with AsyncPostBackTrigger. It will only work with PostBackTrigger.
SOLUTION : If You want to upload file with AsyncPostBackTrigger than you have to use ajaxtoolkit. And in AjacToolkit their is Control name with "AsyncFileUpload".
Hope You know how to add AjaxToolkit to your Toolbox. If you dont know than tell me i will guide you.

这篇关于asp.net的UpdatePanel PostBackTrigger触发完全回发的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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