Open report in second window

Posted on 2007-07-23
Last Modified: 2013-11-26
I am using VB in VS 2003.
After choosing data in a web form the user clicks a button. A CR report is
produced and saved in a temporay file. CrystalReportViewer is used to present
the report. My problem is that I want to present the report in a separate
window. Note that the report must first be produced based on actual data. Is there a solution for this problem?
Question by:Eje2
    LVL 42

    Expert Comment

    You can obviously put the viewer on a different form but do you mean a window separate from the one the viewer is on?  If so, you can always export to pdf format and save the pdf document and then open a new window that points to that document.

    Author Comment

    If I understand you right this means the user must click buttons twice. Once to produce the report and once to display it. I think it looks more proffessional to have only one button "Show report"
    LVL 42

    Expert Comment

    No, you don't need to click twice.  For example, you can have a button on one form that will instantiate a reportdocument object and export it to pdf, then do a server.redirect to the pdf file.  There are lots of ways to handle the display of reports - perhaps if you can explain exactly what you'd like to do then I can tell you how?

    Author Comment

    Today the user can view the document in a separate window with Acrobat reader. But the user must use the Back-button on Internet Explorer to come back to the application. If the user instead uses the exitbutton (X) he also looses the connection with the application. That's why I want a separate window to display the report. The user doesn't loose connection with the application independant of how he handles the window where the report is displayed

    Author Comment

    Sorry. I was writing my comment before I saw yours. This is the code I use today.

          If FName.Trim.Length = 0 Then
            Response.Write("Ingen utskrift skapad")
            Response.ContentType = "application/pdf"
          End If
    LVL 42

    Expert Comment

    What you want to do is from your primary application open a new window.  For example to do this based on a button click apply code like this to your page_load:

       Dim newurl As String = Request.ApplicationPath + "new_window.aspx"
       LinkButton1.Attributes.Add("onclick", "'url', '" + newurl + "', 'menu=no, status=no');return false;");

    Replace "newurl" with the url of a new page.  On this new page you can generate the report, save it to a pdf file, then redirect to the pdf document (or you can simply display in a CRViewer, or you can stream it to the browser, etc.).  The key is that the report is executed and viewed in the new window that opens so when they close this window your primary application window is still open and they don't lose the connection.
    LVL 42

    Accepted Solution

    I believe my last comment ( 19550239 ) answered the question.


    Featured Post

    How to improve team productivity

    Quip adds documents, spreadsheets, and tasklists to your Slack experience
    - Elevate ideas to Quip docs
    - Share Quip docs in Slack
    - Get notified of changes to your docs
    - Available on iOS/Android/Desktop/Web
    - Online/Offline

    Join & Write a Comment

    Wouldn’t it be nice if you could test whether an element is contained in an array by using a Contains method just like the one available on List objects? Wouldn’t it be good if you could write code like this? (CODE) In .NET 3.5, this is possible…
    There have always been a lot of questions related to when Crystal Reports evaluates report components (such as formulas, summaries, cross-tabs, charts, to name a few examples). Crystal Reports uses a two-pass reporting process to provide greater …
    To add imagery to an HTML email signature, you have two options available to you. You can either add a logo/image by embedding it directly into the signature or hosting it externally and linking to it. The vast majority of email clients display l…
    Internet Business Fax to Email Made Easy - With eFax Corporate (, you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, fr…

    728 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    19 Experts available now in Live!

    Get 1:1 Help Now