简体   繁体   中英

opening multiple browser tabs but only one will open

I have a scenario where I loop through a data set (max of 6 records) and then open a new browser tab for each record - each tab shows an invoice for one of the records - not the best design but it's what was requested.

I'm using the code below within a foreach to build a url and open a new browser tab, the problem is it loops through ok but only ever opens 1 new tab. Every other thing happening in the loop works so the problem seems to be with the code. It opens the first tab for the first record then no more after that. Can anyone comment on what's wrong?

            string pageurl = "Label.aspx?booking=" + v.booking + "&pallet=" + v.palletId;
            ScriptManager.RegisterStartupScript(Page, Page.GetType(), "popup", "window.open('" + pageurl + "','_blank')", true);

You can only have one startup script. Try putting all of your window.open calls in a single script;

//This code inside loop
string pageurl = "Label.aspx?booking=" + v.booking + "&pallet=" + v.palletId;
string script += "window.open('" + pageurl + "','_blank'); "

//This code outside loop
ScriptManager.RegisterStartupScript(Page, Page.GetType(), "popup", script, true);

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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