【问题标题】:How to open the multiple pdf files in a new windows using asp.net如何使用asp.net在新窗口中打开多个pdf文件
【发布时间】:2013-04-24 04:45:46
【问题描述】:

在我的应用程序中有带有复选框的网格视图,选择多个复选框单击打印按钮在单独的窗口中打开 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文件,请给我建议。

【问题讨论】:

  • 感谢您的接受和投票,非常感谢!

标签: asp.net c#-4.0 pdf itextsharp scriptmanager


【解决方案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);

【讨论】:

  • 嗨。我正在尝试这段代码。它创造了奇迹。唯一的问题是,加载所有弹出窗口后,我的主页是空的。弹出窗口打开后如何让主页正确加载。
猜你喜欢
  • 1970-01-01
  • 2014-05-01
  • 1970-01-01
  • 1970-01-01
  • 2010-10-02
  • 2014-07-01
  • 2016-08-03
  • 2012-01-14
  • 1970-01-01
相关资源
最近更新 更多