简体   繁体   中英

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');";

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

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM