Sample code to download a file by submitting a form

pavankumarr 1 Tallied Votes 5K Views Share
    <head runat="server">
        <title>Untitled Page</title>

        <script type="text/javascipt">
    function startDownload()
    {
    var url='E:files\\sample.pdf'; 
    window.open(url,'Download');
    }
    </script>
    </head>


    <body>
        <form id="form1" runat="server">
        <script type="text/javascript">
            function openPopup()
            {
                popupwindow=window.open("Form.aspx",'WinName','width=900,height=500,left=200,top=200');
            }
            s=alert("show");
             s1=setTimeout("startDownload()",10000); 

        </script>

         <div>

              <a href="" onclick="openPopup();return false" target="_blank">Click here to view Brochure</a>
        </div>
        </form>
        </body>
LastMitch commented: Thanks for sharing +12
Hi,

I want to download file(pdf) using save dialog when user clicks a link from Html Page.

There is html page where i used anchor tag to open a PopUp window(aspx form) where user will enter his details

and submit the details which will save in database.After submitting the details save dialog window will open where 

user can save the file on his local m/c.

The first part i had completed where user can save the details in datbase.

But after submitting the details I&#39;m not able to open the save dialog or not able to download the from.

Please find my code.

       
Please help me regadring the issue of downloading or saving the file.


Thanks in Advance
Pavan Kumar R
Member Avatar for LastMitch
LastMitch

I don't understand your code snippet. I manage to make the pdf open in a new window but not sure what you mention above.

Overall, it works. Thanks for sharing.

I attached an image on how it looks:
bd81f7c46209253df53ead66cba9d34b

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.