2013-04-30 42 views
0

在我的應用程序中有複選框的網格視圖,選擇多個複選框單擊打印按鈕在單獨的窗口中打開pdf。 我的代碼是如何使用asp.net在新窗口中打開多個pdf文件

for (int i = 0; i < grdAdditionalInsured.Rows.Count; i++) 
{ 
    CheckBox chk = (CheckBox)grdAdditionalInsured.Rows[i].Cells[0].FindControl("chkAdditionalInsured"); 

    if (chk.Checked == true) 
    { 
     //**some code to get the id based on values** 
     string file = "/CertPrints/" + id.ToString() + ".pdf"; 
     String js = @"WindowPopup('" + file + "');"; 
     ScriptManager.RegisterStartupScript(this, this.GetType(), file, js, true); 
    } 
} 

上面的代碼只顯示最後一個記錄pdf文件,請給我建議。

+0

感謝並接受了投票非常感謝! – bUKaneer 2013-04-30 11:12:21

回答

1

試試這個:

StringBuilder js = new StringBuilder(); 
for (int i = 0; i < grdAdditionalInsured.Rows.Count; i++) 
{ 
    bool checked = ((CheckBox)grdAdditionalInsured.Rows[i].Cells[0].FindControl("chkAdditionalInsured")).Checked; 
    if (checked) 
    { 
     //**some code to get the id based on values** 
     js.AppendFormat(@"WindowPopup('/CertPrints/{0}.pdf');",id)); 
    } 
} 
ScriptManager.RegisterStartupScript(this, this.GetType(), "filePopup", js.ToString(), true); 
+0

嗨。 我正在試着此代碼。它創造奇蹟。唯一的問題是,加載所有彈出窗口後,我的主頁是空的。如何在彈出窗口打開後正確加載主頁面。 – jitendragarg 2015-03-13 14:03:44

相關問題