2015-08-21 113 views
0

我在嵌套數據列表中有一個Imagebutton 當我單擊圖像按鈕時,我必須打開一個pdf文件。我在後面的代碼中嘗試了window.open()方法。但它根本不工作。也嘗試了OnClientClick事件。在此先感謝在asp.net中的新選項卡中打開pdf頁面

+0

你是什麼意思「'window.open()'不工作」?它應該工作,否則應該拋出一個錯誤。那麼什麼是錯誤? –

+0

[try {string [] trim = selectedItems [index] .Split('['); DataSet pdfname = ctrl.GetPDFName(trim [0]); string pdf = pdfname.Tables [0] .Rows [0] [0] .ToString();如果(pdf!=「」|| pdf!= null) { Response.Redirect(「〜/ PDF FILES /」+ pdf,false); } 別的 { //警報消息 } } 趕上(異常前) { }] – Sethu

+0

window.open不投擲錯誤。但是,當我點擊按鈕 – Sethu

回答

0

剛剛嘗試過,這會在新選項卡中打開PDF。

<asp:ImageButton ImageUrl="/Content/sample.jpg" runat="server" Width="100" 
     OnClientClick="javascript:window.open('/Content/sample.pdf'); return false;" /> 
+0

我看過你的意見,imgBtn.Attributes.Add()似乎適合你。你還有問題嗎?如果是,請發佈您的代碼(datalist aspx和item命令事件處理程序)。如果沒有,請關閉帖子。它造成混亂。 – niksofteng

相關問題