hello all , i have this code below , when you click on the link button ,it will open the Details page of the news .. the reason of using this code is to increase the Visit no, of the link
LinkButton lbtn = sender as LinkButton;
if (lbtn != null)
DA.UpdateVisitNo(lbtn.CommandArgument, 0);
Response.Redirect("Details.aspx?NewsID=" + lbtn.CommandArgument);
}
}
now , in my table there is a field for the File name with extention , for example MyCV.doc , Refrence.pdf ....,.
what i want now instead of this Response.Redirect("Details.aspx?NewsID=" + lbtn.CommandArgument); , i want to open the linked file .. to the Link button ,
Instead of doing a linkbutton to update the visit number, why not just put it in the page you are redirecting to? For the way that you are doing it, you have to use response.redirect because, at this point, the linkbutton has already posted back as a command
event so it's job is done. That leaves response.redirect as the only way to go here.
Don't forget to mark useful responses as Answer if they helped you towards a solution.
If you want to download the file to client, you need to using a generic handler. It handles all the requests made for the download which will meet your reqirement. For details, please check the link ramiramilu provided.
Best wishes,
Please mark the replies as answers if they help or unmark if not.
Feedback to us
i tried your code , and its working fine but there is some problem :
1- if there is one image inside the image folder , and this image is assigned to different things or articles ..it only show one dowload image with one download link ...
2- in my case what i want is instead of word Download , i would like to place the Title of my subject and when they click it download the linked file ...
3- also i want to mix this code with a gride view for example
Name of the Photo photographer name Date Taken Download
siamand
Member
416 Points
307 Posts
How to do dynamic link to a pdf files , using this code below :
Apr 25, 2012 01:23 PM|LINK
hello all , i have this code below , when you click on the link button ,it will open the Details page of the news .. the reason of using this code is to increase the Visit no, of the link
LinkButton lbtn = sender as LinkButton; if (lbtn != null) DA.UpdateVisitNo(lbtn.CommandArgument, 0); Response.Redirect("Details.aspx?NewsID=" + lbtn.CommandArgument); } }now , in my table there is a field for the File name with extention , for example MyCV.doc , Refrence.pdf ....,.
what i want now instead of this Response.Redirect("Details.aspx?NewsID=" + lbtn.CommandArgument); , i want to open the linked file .. to the Link button ,
i hope you got what i mean
Regards
markfitzme
All-Star
15343 Points
2358 Posts
Re: How to do dynamic link to a pdf files , using this code below :
Apr 25, 2012 01:49 PM|LINK
Instead of doing a linkbutton to update the visit number, why not just put it in the page you are redirecting to? For the way that you are doing it, you have to use response.redirect because, at this point, the linkbutton has already posted back as a command event so it's job is done. That leaves response.redirect as the only way to go here.
ramiramilu
All-Star
97799 Points
14494 Posts
Re: How to do dynamic link to a pdf files , using this code below :
Apr 25, 2012 02:36 PM|LINK
Open/Download files on Click from server to client - http://www.intstrings.com/ramivemula/asp-net/how-to-download-files-from-server-to-client-using-a-generic-handler/
so you need to pass something specific to the file to handler or page and then make it download...
Thanks,
JumpStart
siamand
Member
416 Points
307 Posts
Re: How to do dynamic link to a pdf files , using this code below :
Apr 27, 2012 08:22 AM|LINK
thanks for your reply
all i want is instead of redirecting the link button , download the file
Response.Redirect("Details.aspx?NewsID=" + lbtn.CommandArgument);
Catherine Sh...
All-Star
23382 Points
2490 Posts
Microsoft
Re: How to do dynamic link to a pdf files , using this code below :
May 02, 2012 10:00 AM|LINK
Hi siamand,
If you want to download the file to client, you need to using a generic handler. It handles all the requests made for the download which will meet your reqirement. For details, please check the link ramiramilu provided.
Best wishes,
Feedback to us
Develop and promote your apps in Windows Store
siamand
Member
416 Points
307 Posts
Re: How to do dynamic link to a pdf files , using this code below :
May 06, 2012 08:02 AM|LINK
Thank you very much for your help
i tried your code , and its working fine but there is some problem :
1- if there is one image inside the image folder , and this image is assigned to different things or articles ..it only show one dowload image with one download link ...
2- in my case what i want is instead of word Download , i would like to place the Title of my subject and when they click it download the linked file ...
3- also i want to mix this code with a gride view for example
Name of the Photo photographer name Date Taken Download
Regards