framwork3.5存在多个文件选择问题 [英] Multiple File selection issue with framwork3.5

查看:66
本文介绍了framwork3.5存在多个文件选择问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

An issue occur while performing multiFile selection in framework 3.5. I am using 'jquery.MultiFile.js' and 'jquery-1.8.2.js' scripts to achieve it. My attachment control is inside a update panel within Tab control. Everything is fine but when i am use async or full post back then file uploader control can not read script and can not select multiple files. My Code part is as follows :


<script src="../Scripts/jquery.MultiFile.js" type="text/javascript"></script>
    <script src="../Scripts/jquery-1.8.2.js" type="text/javascript"></script>

    <div class="PageMainTable">
        <ajaxToolkit:TabContainer ID="TabContainer1" runat="server" AutoPostBack="true" ActiveTabIndex="1"

            OnActiveTabChanged="TabContainer1_ActiveTabChanged">
            <ajaxToolkit:TabPanel ID="tb_home" runat="server" HeaderText="Home">
            </ajaxToolkit:TabPanel>
            <ajaxToolkit:TabPanel ID="TabPanel1" runat="server" HeaderText="CSR Registration Process">
                <ContentTemplate>
                    <asp:UpdatePanel ID="up_addupdt" runat="server" UpdateMode="Conditional" >
                        <Triggers>
                            <asp:PostBackTrigger ControlID="btn_save" />

                        </Triggers>
                        <ContentTemplate>
.....
 <tr>
                                    <td class="lbl_text">Attachment:
                                    </td>

                                    <td colspan="4">
                                        <asp:FileUpload ID="FileUpload1"

                                            maxlength="5" runat="server" class="multi" />

                                    </td>
                                    <td align="left" colspan="4">
                                        <asp:Label ID="lbl_attach" runat="server" Text="" Visible="false"></asp:Label>
                                    </td>
                                </tr>
...
 </ContentTemplate>
                        <Triggers>
                            <asp:AsyncPostBackTrigger ControlID="drop_system" EventName="SelectedIndexChanged" />
                        </Triggers>
                    </asp:UpdatePanel>

                </ContentTemplate>
            </ajaxToolkit:TabPanel>


On async post back of drop down (drop_system) file uploader behave normal and could not allow me to select multiple files.

Pls reply to my query as early as possible.
Thanx in advance.

推荐答案

出于安全原因,无法为上传控件提供默认文件路径,因此当您的updatepanel将刷新fires和上传控件,它们会丢失之前指向的文件。这就是文件上传的工作原理,你无能为力。即使这确实有效,也无法在更新面板中异步上传文件。更新面板和外部jQuery脚本的另一个问题是,最初为使脚本工作而附加的事件现在不再起作用,因为它们最初附加到的控件已被销毁并由更新面板重新创建。要解决此问题,您需要更改将事件附加到控件的方式。



http://forums.asp.net/t/1982846.aspx?How+to+run+javascript+after+updatepanel+execution+已完成 [ ^ ]



基本上......不要在更新面板中使用文件上传控件,找到另一种方法来做你所做的事情重做。
Upload controls can't be given default file paths for security reasons, so when your updatepanel fires and the upload controls are refreshed, they lose the files they were previously pointing to. That is just how file uploads work, there is nothing you can do about it. Even if this did work, you can't asynchronously upload files in an update panel anyway. The other problem with update panels and external jQuery scripts is that the events you attached originally to make the scripts work now no longer work because the controls they were originally attached to have been destroyed and recreated by the update panel. To fix this you need to change how you attach the events to the controls.

http://forums.asp.net/t/1982846.aspx?How+to+run+javascript+after+updatepanel+execution+completed[^]

Basically...don't use file upload controls inside update panels, find another way to do what you're doing.


这篇关于framwork3.5存在多个文件选择问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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