0
이미지 버튼을 처음 클릭 할 때마다 아무 것도 나타나지 않고 두 번째 클릭 할 때 파일을 새 창으로 열 때마다 이미지 버튼 onClientClick 이벤트에 대한 새 창으로 PDF 파일을 열려고합니다. 첫 번째 클릭시 파일을 열려고합니다.OnClientClick이 작동하지 않습니다. 처음으로
나는 아래 언급 된 코드를 사용했습니다.
//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');";
문자열 변수 filePath가 "\\ OnlineContent \\/{value}"로 초기화된다는 사실을 알고 있습니까? –
'window.open '사용은 항상 나쁜 생각입니다. 많은 브라우저/플러그인/바이러스 스캐너가이를 차단할 수 있습니다. – VDWWD
예 @MasterYoda를 알고 있습니다 – WeeZy