• 模态窗口,解决下载问题


    代码如下:

        <base id="goDownload" target="_self" />
        <script type="text/javascript">
            function showMsg()
            {
               var downloadBase=document.getElementById("goDownload");
               var downloadBox=document.getElementById("download");
               download.src=document.URL;
               downloadBase.target="download";
               setTimeout("CancelMsg()",1000);
            }
            function CancelMsg()
            {
               var downloadBase=document.getElementById("goDownload");
               downloadBase.target="_self";
            } 
        </script>
    
        <table width="700px" border="0" cellpadding="0" cellspacing="0" align="center" style=" margin-top:10px;">
            <asp:Repeater ID="RepeaterFileManager" runat="server" OnItemCommand="RepeaterFileManager_OnItemCommand">
                <HeaderTemplate>
                    <tr align="center" valign="middle" style="background-color:#A4E3F4;">
                       <td style="100px; height:42px;" class="td13">年  级</td>
                       <td style="150px; height:42px;" class="td13">班级名称</td>
                       <td style="150px; height:42px;" class="td13">课程名称</td>
                       <td style="100px; height:42px;" class="td13">上传教师</td>
                       <td style="100px; height:42px;" class="td13">文件类型</td>
                       <td style="100px; height:42px;" class="td14">下载</td>
                    </tr>
                </HeaderTemplate>
                <ItemTemplate>
                    <tr align="center" valign="middle" style="background-color:White;">
                       <td style="100px; height:32px;" class="td15"><%# Eval("SYear") %>_<%# Eval("STerm") %></td>
                       <td style="150px; height:32px;" class="td15">
                          <%# Convert.ToInt32(Eval("FileManagerClassID")) == 1 ? Convert.ToInt32(Eval("ClassID")) == -1 ? Eval("Course.Vocational.VocationalName") : Eval("ClassInfo.ClassName") : "&nbsp;"%>
                       </td>
                       <td style="150px; height:32px;" class="td15"><%# Eval("Course.CourseName") %></td>
                       <td style="100px; height:32px;" class="td15"><%# Eval("Teacher.TeaName") %></td>
                       <td style="100px; height:32px;" class="td15"><%# Eval("FileManager_Class.ClassName")%></td>
                       <td style="100px; height:32px;" class="td16">
                         <asp:LinkButton ID="linkBtDownLoad" runat="server" CommandArgument='<%# Eval("Id") %>' 
                             CommandName="goDown" OnClientClick="showMsg()">下载</asp:LinkButton>
                       </td>
                    </tr>
                </ItemTemplate>
            </asp:Repeater>
        </table>
    
        <iframe id="download" src="FileManager.aspx" name="download" height="0" width="0"></iframe>

    思路:
    遇到这个问题的朋友知道:
    问题一:<base target="_bank" /> 下载没问题,可是会打开新窗口,用户体验不好
    问题二:<base target="_self" /> 下载框,弹不出来
    问题三:<base id="goDownload" target="_self" /> <iframe id="download" src="FileManager.aspx" name="download" height="0" width="0"></iframe>
            下载是没问题了,但是下载后分页查询的效果没了、、、
    最终解决方案:
    如上代码,加上两个方法,设置延迟函数。需要下载的时候,把<base id="goDownload" target="_self" />改动指向iframe(id为download)
    这样就可以弹出下载框了,在一秒后又设成_self,这样又回到最初状态,查询也没问题了

  • 相关阅读:
    DataTables 控件使用和心得 (2)
    dataTables 添加行内操作按钮
    datatables 配套bootstrap3样式使用小结(1)
    loadrunner总体使用篇
    使用CEF类库处理HTTP请求
    27部优秀的黑客纪录片
    CEF3开发者系列之进程和线程
    cef3的各个接口你知道几个
    [你必须知道的.NET]第二十九回:.NET十年(上)
    [你必须知道的.NET]第二十八回:说说Name这回事儿
  • 原文地址:https://www.cnblogs.com/jery0125/p/2933299.html
Copyright © 2020-2023  润新知