.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
 
Sign In
Register
 
Win Surprise Gifts!!!
Congratulations!!!


Top 5 Contributors of the Month
david stephan

Home >> Forum >> ASP.Net >> Post New QuestionBookmark and Share Subscribe to Forum

Opening the image or file in new window using button click

Posted By: Catherine     Posted Date: November 19, 2012    Points:5   Category :ASP.Net
Dear All,

How to open the image or document using the button click without browsing the file name.In textbox the file name will be given when the button is click the file should open. Please do the needful.

Responses
Author: Murugan             
Posted Date: November 21, 2012     Points: 20   

try this code
Process.Start("path to image file");

path to image file=> give the path from textbox as input


Author: Baimey Rajesh             
Posted Date: December 05, 2012     Points: 20   

If it is a pdf file
check this link http://forums.asp.net/t/1219837.aspx

Response.Redirect("~/somePDFFile.pdf");


or

using System.Net;
string pdfPath = Server.MapPath("~/SomePDFFile.pdf");
WebClient client = new WebClient();
Byte[] buffer = client.DownloadData(pdfPath);
Response.ContentType = "application/pdf";
Response.AddHeader("content-length", buffer.Length.ToString());
Response.BinaryWrite(buffer);


this might work for other files as well

Thanks
Baimey

Author: Baimey Rajesh             
Posted Date: December 05, 2012     Points: 20   

Else u can see
protected void btnPurchaseOrderOpen_Click(object sender, EventArgs e)
{
Response.Clear();
Response.ContentType = "application/pdf";
Response.AddHeader("content-disposition", "attachment;filename=one.pdf");
Response.TransmitFile(@"c:\test\one.pdf");
Response.End();
}


See the link :: http://stackoverflow.com/questions/2084945/how-to-open-an-word-document-on-click-of-link-button



Post Reply

You must Sign In To post reply
 
 
Find more Forum Questions on C#, ASP.Net, Vb.Net, SQL Server and more Here
Quick Links For Forum Categories:
ASP.NetWindows Application  .NET Framework  C#  VB.Net  ADO.Net  
Sql Server  SharePoint  OOPs  SilverlightIISJQuery
JavaScript/VBScriptBiztalkWPFPatten/PracticesWCFOthers
www.DotNetSpark.comUnAnsweredAll

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend