Dharmin Gheewala
Dharmin Gheewala

Reputation: 99

OnClientClick not working First Time

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

Answers (1)

user7671438
user7671438

Reputation:

Use .. (double dot) or ~ (tilde sign) before \OnlineContent.

string strFilePath = "\OnlineContent\"; string filePath = strFilePath +"/"+ hdnFileName.Value;

Upvotes: 1

Related Questions