C# Tutorials and offshore development in India
    Tutorials   Resources   Forum   Communities   Interview   Jobs   Projects   Offshore Development    
Silverlight Tutorials | Mentor | Code Converter | Articles | Code Factory | Computer Jokes | Members | Peer Appraisal | IT Companies | Bookmarks | Revenue Sharing |


Prizes & Awards
My Profile



Active Members
TodayLast 7 Days more...

New Feature: Community Sites: Create your own .NET community website and start earning from Google AdSense ! It's Free !




how to download image from web folder


Posted Date: 04 Aug 2008      Total Responses: 2

Posted By: Bachan rawat       Member Level: Silver     Points: 1



Hi All,
In asp.net and c#, how to download image or pdf from my web folder and save at clients desktop.

Thanks & Regard
BSR......





Responses

Author: Ravi Kiran.T    04 Aug 2008Member Level: GoldRating:     Points: 2

Ex: <a href="../downloads/example1.pdf">Download From Here</a>

Here "downloads" is the remote folder where we can download from.



Author: Mexi Renjith Mamman    05 Aug 2008Member Level: GoldRating:     Points: 6


In asp.net with C# you can do it as:

You can either display it in a repeater or else you can just get the file to download from DB.

Using Repeater:

<asp:Repeater ID="repDwnldDetails" runat="server" OnItemDataBound="repDetails_ItemDataBound">
<ItemTemplate>
<table cellpadding="0" cellspacing="0" border="0">
<tr>
<td>
<asp:Literal ID="ltDownloadName" runat="server" ></asp:Literal></td>
<td>
<asp:HyperLink ID="lnkDownloadFilename" runat="server" NavigateUrl="#" Text="File" Target="_blank"> </asp:HyperLink> </td>
</tr>
</table>
</ItemTemplate>
</asp:Repeater>

Bind the repeator with needed fields:
In the .cs page:

protected void repDetails_ItemDataBound(object sender, RepeaterItemEventArgs e)
{
if (e.Item.ItemType == ListItemType.Item ||
e.Item.ItemType == ListItemType.AlternatingItem)
{
Literal ltDwnldName = (Literal)e.Item.FindControl("ltDownloadName");
HyperLink lnkDownloadFilename = (HyperLink)e.Item.FindControl("lnkDownloadFilename");
lnkDownloadFilename.NavigateUrl = "Download/" +
drvDetails["down_download_stored_filename"].ToString();
}
}

The file can be downloaded like this

Without using repeator control you can place a hyperlink and call the filename as above.



Post Reply
You must Sign In to post a response.
Next : Calling Windows Service from ASP.NET Web App
Previous : datagrid/repeater control
Return to Discussion Forum
Post New Message
Category: ASP.NET

Related Messages



dotNet Slackers   BizTalk Adaptors    Web Design


Contact Us    Privacy Policy    Terms Of Use