简体   繁体   English

如何从后面的代码打开多个页面?

[英]How to open multiple pages from code behind?

I have a page that exports a PDF file via parameters that will be passed to it from query string. 我有一个页面通过参数导出PDF文件,该参数将从查询字符串传递给它。 For example: 例如:

PrintPage.aspx?CustomerId=1

will export a PDF with information about the customer #1. 将导出包含有关客户#1的信息的PDF。

now I have an ImageButton in another page (Lets call it CallerPage.aspx) and I want to call PrintPage.aspx multiple times with multiple query string values like this: 现在我在另一个页面中有一个ImageButton(让我们将其称为CallerPage.aspx),并且我想使用多个查询字符串值多次调用PrintPage.aspx:

foreach (Customer customer in Customers)
{
    HyperLink lnk = new HyperLink();
    lnk.NavigateUrl = "PrintPage.aspx?CustomerID=" + customer.ID;
    lnk.Target = "_blank";
}

But I don't know how to navigate the hyperlinks that I've created. 但是我不知道如何导航我创建的超链接。

I've also tried Response.Redirect but it doesn't work as well 我也尝试过Response.Redirect,但效果不佳

foreach (Customer customer in Customers)
{
    Response.Redirect("PrintPage.aspx?CustomerID=" + customer.ID, false);
}

It only redirects to the last page (and without the false parameter it will redirects to the first page) 它仅重定向到最后一页(没有false参数,它将重定向到第一页)

So please help me with this. 所以请帮我。 Thanks 谢谢

Once sent to client you cannot open new URL from the code behind. 一旦发送给客户,您将无法从后面的代码中打开新的URL。 You need javascript to do that. 您需要使用javascript来做到这一点。 If you attache handler to onload page event you could open as many pages as you want. 如果将处理程序附加到onload页面事件,则可以打开任意多个页面。 The other point is whether the client would like that ;-) 另一点是客户是否愿意;-)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM