javascript - ASP.NET iframe doesn't update, sometimes -
below simplified .aspx file. after clicking 'update preview' button iframe containing modified .pdf file shows date file. sometimes, though, takes several clicks until iframe shows date file.
even if redirect file directly in new window, .pdf file still not date! (on server's disk is, though)
<%@ page language="c#" autoeventwireup="true" codebehind="webform1.aspx.cs" inherits="pdfwebform.webform1" %> <script runat="server"> void download_click(object sender, eventargs e) { response.redirect("http://dev-db-02/pdf/catalog.pdf"); } void button1_click(object sender, eventargs e) { string answer = call_pdf(make_new, retails_array, restypes_array, selected_kids, brands_array); if (answer != "failed") { label1.text = "done!"; } else { label1.text = "no models meet selected criteria."; } } </script> <!doctype html> <html xmlns="http://www.w3.org/1999/xhtml"> <head runat="server"> <title>generate pdf catalog</title> <link href="theme.css" rel="stylesheet" type="text/css" /> <!-- <style type="text/css"> .auto-style1 { width: 100%; height: 105px; } .auto-style2 { width: 557px; } </style> --> <style type="text/css"> .auto-style1 { width: 84%; } .auto-style2 { text-align: left; width: 87px; } .auto-style3 { text-align: left; width: 486px; } </style> </head> <body> <script type="text/javascript"> function appear() { document.getelementbyid("preview").style.display = 'block'; } </script> <script type="text/javascript"> function updatepreview() { if (document.getelementbyid("label1").innerhtml != "") { var iframe = document.getelementbyid("preview1"); iframe.src = iframe.src; iframe.src = iframe.src; iframe.src = iframe.src; } else{ document.getelementbyid("label1").innerhtml = "please wait..."; } } </script> <script type="text/javascript"> function update_iframe() { var iframe = document.getelementbyid("preview1"); iframe.src = iframe.src; iframe.src = iframe.src; iframe.src = iframe.src; } </script> <script type="text/javascript"> function dot() { if (document.getelementbyid("label1").innerhtml == "d") { document.getelementbyid("label1").innerhtml = "nope"; } else { document.getelementbyid("label1").innerhtml = "d"; } } </script> <h1>generate pdf catalog</h1> <form id="form1" runat="server"> <!-- <embed id="preview" src="http://dev-db-02/pdf/catalog.pdf" width="500px" height="500px" runat="server" /> --> <iframe id="preview1" src="http://dev-db-02/pdf/catalog.pdf" width="500" height="500" runat="server"></iframe> <!-- add file feature <asp:radiobuttonlist id="radiobuttonlist1" runat="server"> <asp:listitem selected="true" value="new">create new pdf</asp:listitem> <asp:listitem value="old">add existing pdf</asp:listitem> </asp:radiobuttonlist> --> <table class="auto-style1"> <tr> <td class="auto-style2"> <b>retail:<br /> </b> <asp:listbox id="listbox5" runat="server" height="45px" selectionmode="multiple" width="230px"> <asp:listitem selected="true" value="yes">yes</asp:listitem> <asp:listitem value="no">no</asp:listitem> </asp:listbox> <b> <br /> <br /> res type:</b><br /> <asp:listbox id="listbox4" runat="server" selectionmode="multiple" height="69px" width="230px"> <asp:listitem selected="true" value="optical">optical</asp:listitem> <asp:listitem value="kids">kids</asp:listitem> <asp:listitem value="sun">sun</asp:listitem> </asp:listbox> <br /> <br /> <b>brand:</b><br /> <asp:listbox id="listbox3" runat="server" height="142px" width="230px" selectionmode="multiple" > <asp:listitem selected="true" value="'as'">aspire</asp:listitem> <asp:listitem value="'bcbg'">bcbgmaxazria</asp:listitem> <asp:listitem value="'cvo'">clearvision</asp:listitem> <asp:listitem value="'ch'">cole haan</asp:listitem> <asp:listitem value="'dd'">dilli dalli</asp:listitem> <asp:listitem value="'dh'">durahinge</asp:listitem> <asp:listitem value="'et'">ellen tracy</asp:listitem> <asp:listitem value="'izod'">izod</asp:listitem> <asp:listitem value="'izx'">izod performx</asp:listitem> <asp:listitem value="'jmc'">jessica mcclintock</asp:listitem> <asp:listitem value="'jc'">junction city</asp:listitem> <asp:listitem value="'me'">marc ecko</asp:listitem> <asp:listitem value="'op'">ocean pacific</asp:listitem> <asp:listitem value="'pt'">puriti</asp:listitem> </asp:listbox> <br /> <br /> <br /> </td> <td colspan="3"> <asp:label id="label1" runat="server" font-bold="true" onchange="updatepreview()"></asp:label> <br /> <!-- <embed id="preview" src="http://dev-db-02/pdf/catalog.pdf" width="500px" height="500px" runat="server" /> --> <iframe id="preview1" src="http://dev-db-02/pdf/catalog.pdf" width="500" height="500" runat="server"></iframe> <br /> <!-- <iframe id="frame" style="display:none"></iframe> --> <!-- <a href="javascript:download('http://dev-db-02/pdf/catalog.pdf')">download</a> --> </td> </tr> <tr> <td class="auto-style2"> <asp:button id="button1" runat="server" font-bold="true" font-names="verdana" font-size="12" onclick="button1_click" onclientclick="updatepreview()" text="submit"></asp:button> </td> <td class="auto-style3"> *<font size="3">hold control/command <br /> + click select multiple</font> </td> <td class="auto-style3"> <font size="3"> <asp:button id="button2" runat="server" text="update preview" onclientclick="update_iframe()" /> </font> </td> <td class="align-right"> </td> </tr> </table> <br /> <br /> </div> </form> <script type="text/javascript"> function download() { window.open("http://dev-db-02/pdf/catalog.pdf"); } </script> </body> </html>
void download_click(object sender, eventargs e) { response.contenttype = "application/pdf"; response.appendheader("content-disposition", "attachment; filename=help.pdf"); response.transmitfile(server.mappath("~/pdf/catalog.pdf")); response.end(); } in case redirecting response 301 url witch return file, problem using 301 redirect , if changing disk file browser return cached 301 redirect (same file)
Comments
Post a Comment