Click here to Skip to main content
15,887,363 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
I have a code that when a user clicks on submit button the data is submitted to the database and two CR viewer should popup for printing. Right now only one pops up. What do I need in my code to have both CR viewer to popup for printing?

C#
if (Page.IsValid)
            {
                TextBoxUser_ID.Text = Session["user_id"].ToString();
                ClientScript.RegisterStartupScript(this.GetType(), "onclick", "<script language=javascript>window.open('ReportFormFTE.aspx','PrintMe','height=650px,width=950px,scrollbars=1');</script>");
                ClientScript.RegisterStartupScript(this.GetType(), "onclick", "<script language=javascript>window.open('ReportFormGrad.aspx','PrintMe','height=650px,width=950px,scrollbars=1');</script>");
                ScriptManager.RegisterStartupScript(this, typeof(Page), "myscript", "alert('You have successfully submitted the electronic portion of the General and Enrollment Profile.  Please send your signed Profile along with any required attachments to SACSCOC, Attn: Profiles, 1866 Southern Lane, Decatur, Ga 30033.');location.href='WelcomeMenu.aspx';", true);
            }
        }
Posted
Updated 30-Oct-14 4:59am
v2
Comments
Kschuler 30-Oct-14 10:17am    
It depends. Are these CR Viewers supposed to be displaying different reports? If so, how are they different? Is it a different webpage that you open up? Or do both use ReportFormFTE.aspx? And if they both use the same webpage, then how do you distinguish which report should display?
Computer Wiz99 30-Oct-14 10:30am    
Yes, they are two different reports in two different CR viewers. One is ReportFormFTE.aspx and the other is ReportFormGrad.aspx. Do I need to put the code together?
Kschuler 30-Oct-14 10:52am    
First of all...What's with your else if?...you are doing the same check in the IF as you are in the ELSE IF? Basically you need to call the window.open for both of them, but you probably just need to give them different window names. Otherwise it's probably opening the first report in a window, then opening the second report over it. And I don't think you need that IF statement at all. It might not be running the second code. I've never tried something like that.
Computer Wiz99 30-Oct-14 10:57am    
Ok. I have removed that and still no two CR Viewer.
Kschuler 30-Oct-14 11:33am    
Which viewer IS showing?

First get rid of your IF/ELSEIF statement. When stepping through the code in debug you will see that it will only execute the code in the IF portion, and will never execute the code in the ELSE IF portion.

If that doesn't work, try naming the windows differently. Currently you are naming them both "PrintMe". Change one of them to "PrintMe2" or something and see if that works.



---------- Edit ----------
Okay...now I'm thinking it's because you are creating two OnClick events. Can you put the javascript for both window.open calls in a method and then just call that method in the OnClick event?

Here is a link with to a sample that I found:
http://www.java2s.com/Code/JavaScript/Window-Browser/Openmultiplewindowsatoneclick.htm[^]

And here are some other google results that may help:
https://www.google.com/webhp?sourceid=chrome-instant&rlz=1C1EODB_enUS581US581&ion=1&espv=2&ie=UTF-8#q=javascript+window.open+multiple+windows[^]
 
Share this answer
 
v2
Comments
Computer Wiz99 30-Oct-14 11:05am    
PrintMe2 did not work. I also tried to rename the window.open to window.open2 but nothing happened.
Kschuler 30-Oct-14 11:36am    
window.open is the javascript funtion. The second parm is the name that you would give the window. Instead of 'PrintMe' try setting them both to '_Blank'
Kschuler 30-Oct-14 12:30pm    
I updated my solution with another thing to try.
I solved it myself. I just added the other report as a subreport.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900