سؤال

I have a page that exports a PDF file via parameters that will be passed to it from query string. For example:

PrintPage.aspx?CustomerId=1

will export a PDF with information about the customer #1.

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:

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

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)

So please help me with this. Thanks

هل كانت مفيدة؟

المحلول

Once sent to client you cannot open new URL from the code behind. You need javascript to do that. If you attache handler to onload page event you could open as many pages as you want. The other point is whether the client would like that ;-)

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top