Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 217
  • Last Modified:

Open report in second window

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?
0
Eje2
Asked:
Eje2
  • 4
  • 3
1 Solution
 
frodomanCommented:
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.
0
 
Eje2Author Commented:
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"
0
 
frodomanCommented:
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?
0
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 
Eje2Author Commented:
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
0
 
Eje2Author Commented:
Sorry. I was writing my comment before I saw yours. This is the code I use today.

    Try
      Response.ClearContent()
      Response.ClearHeaders()
      If FName.Trim.Length = 0 Then
        Response.Write("Ingen utskrift skapad")
      Else
        Response.ContentType = "application/pdf"
        Response.WriteFile(FName)
      End If
      Response.Flush()
      Response.Close()
0
 
frodomanCommented:
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", "window.open('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.
0
 
frodomanCommented:
I believe my last comment ( 19550239 ) answered the question.

frodoman
0

Featured Post

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

  • 4
  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now