Connecting Tech Pros Worldwide Forums | Help | Site Map

code for downloading a file

CreativeMind
Guest
 
Posts: n/a
#1: Oct 6 '08
hi, I am facing problem in download hyperlink..plz give me the
solution.
in codebehind,
private void repDocuments_ItemDataBound(object sender,
System.Web.UI.WebControls.RepeaterItemEventArgs e)
System.Web.UI.WebControls.HyperLink myLink =
(System.Web.UI.WebControls.HyperLink)repDocuments. Items[i].FindControl("LnkDownLoad");
and in aspx page,
<TD align="left" valign="top" class="GridCell"><a id="LnkDownLoad"
href='../PropertyDocuments/<%#DataBinder.Eval(Container,
"DataItem.PhysicalFileName")%>' class="recordLink 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
Guest
 
Posts: n/a
#2: Oct 6 '08

re: code for downloading a file


On Oct 6, 12:36*pm, CreativeMind <aftab.pu...@gmail.comwrote:
Quote:
hi, I am facing problem in download hyperlink..plz give me the
solution.
in codebehind,
*private void repDocuments_ItemDataBound(object sender,
System.Web.UI.WebControls.RepeaterItemEventArgs e)
*System.Web.UI.WebControls.HyperLink myLink =
(System.Web.UI.WebControls.HyperLink)repDocuments. Items[i].FindControl("Lnk DownLoad");
and in aspx page,
<TD align="left" valign="top" class="GridCell"><a id="LnkDownLoad"
href='../PropertyDocuments/<%#DataBinder.Eval(Container,
"DataItem.PhysicalFileName")%>' class="recordLink 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.AddHeader("Content-Disposition", "attachment;.....

You can find a lot of tutorials for this, for example,
http://www.aspnetmime.com/tutorials/...ToBrowser.aspx

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