0
イメージボタンonClientClickイベントの新しいウィンドウにPDFファイルを開こうとしていますが、画像ボタンをクリックすると何も起こりません。また、2回目にクリックすると新しいウィンドウにファイルが開きます 最初のクリックでファイルを開くだけです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