code for downloading a file

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • CreativeMind

    code for downloading a file

    hi, I am facing problem in download hyperlink..plz give me the
    solution.
    in codebehind,
    private void repDocuments_It emDataBound(obj ect sender,
    System.Web.UI.W ebControls.Repe aterItemEventAr gs e)
    System.Web.UI.W ebControls.Hype rLink myLink =
    (System.Web.UI. WebControls.Hyp erLink)repDocum ents.Items[i].FindControl("L nkDownLoad");
    and in aspx page,
    <TD align="left" valign="top" class="GridCell "><a id="LnkDownLoad "
    href='../PropertyDocumen ts/<%#DataBinder.E val(Container,
    "DataItem.Physi calFileName")%> ' class="recordLi nk LnkAppear">
    Download</a></TD>
    ....now when i click on hyperlink 'download', i see the the file in
    browser window but i want the download dialog , how can i do that??
    thx
  • Alexey Smirnov

    #2
    Re: code for downloading a file

    On Oct 6, 12:36 pm, CreativeMind <aftab.pu...@gm ail.comwrote:
    hi, I am facing problem in download hyperlink..plz give me the
    solution.
    in codebehind,
     private void repDocuments_It emDataBound(obj ect sender,
    System.Web.UI.W ebControls.Repe aterItemEventAr gs e)
     System.Web.UI.W ebControls.Hype rLink myLink =
    (System.Web.UI. WebControls.Hyp erLink)repDocum ents.Items[i].FindControl("L nk DownLoad");
    and in aspx page,
    <TD align="left" valign="top" class="GridCell "><a id="LnkDownLoad "
    href='../PropertyDocumen ts/<%#DataBinder.E val(Container,
    "DataItem.Physi calFileName")%> ' class="recordLi nk LnkAppear">
    Download</a></TD>
    ...now when i click on hyperlink 'download', i see the the file in
    browser window but i want the download dialog , how can i do that??
    thx
    If you want to have the "Save File As" dialog to be presented to the
    client, instead of pointing to the file you have to create a new page
    which would send a content of the file to the browser with a flag to
    force download

    Response.AddHea der("Content-Disposition", "attachment;... ..

    You can find a lot of tutorials for this, for example,


    Another option is to open the link in the new window, using
    target=_blank.. .

    Comment

    Working...