Reputation: 99
I am trying to open PDF file into new window on image button onClientClick event whenever i click on image button first time nothing will happen and when i try to click second time it will open the file into new window i just want to open the file on first click
i used code that below mention.
//Find control in Grid view
GridViewRow row = (GridViewRow (((ImageButton)e.CommandSource).NamingContainer);
HiddenField hdnFileName = (HiddenField)row.FindControl("hdnFilePath");
ImageButton ibtn = (ImageButton)row.FindControl("ibtnDownload");
//Get File Path and FileName and Concate
string strFilePath = "\\OnlineContent\\";
string filePath = strFilePath +"/"+ hdnFileName.Value;
//Open PDF file into new tab
ibtn.OnClientClick = "window.open('"+filePath.ToString()+"','target=_blank');";
Upvotes: 0
Views: 168
Reputation:
Use .. (double dot) or ~ (tilde sign) before \OnlineContent.
string strFilePath = "\OnlineContent\"; string filePath = strFilePath +"/"+ hdnFileName.Value;
Upvotes: 1