Sample code to download a file by submitting a form

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

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

        <form id="form1" runat="server">
        <script type="text/javascript">
            function openPopup()



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

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

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:

Be a part of the DaniWeb community

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