?
Solved

Window.Close NOT working???

Posted on 2013-06-04
10
Medium Priority
?
378 Views
Last Modified: 2013-06-09
OK I've spend way too much time trying to figure this out and now I need some help!

I open a PopUp Window with a Crystal Report:
        Dim PopUpScript As String = "<script language='javascript'>" + "window.open('CrystalReportViewer.aspx?SiteID=" & ddl_Sites.SelectedValue & "&ClientID=" & ddl_Clients.SelectedValue & "&BDate=" & txt_StartDate.Text & "&EDate=" & txt_EndDate.Text & "&Status=" & ddl_Status.SelectedValue & "&Type=" & ddl_LockboxType.SelectedValue & "'" & ",'','width=1000px,height=800px, status=yes, resizable=yes, scrollbars=yes, toolbar=yes,location=yes,menubar=yes').focus();</script>"
        Page.ClientScript.RegisterStartupScript(Me.GetType(), "PopUpWindow", PopUpScript, False)


Then I have a button on the PopUp to close the window:
    Protected Sub cmd_ClosePage_Click(ByVal sender As Object, ByVal e As System.EventArgs)
        CrystalReportSource.Dispose()
        SQLDataSource.Dispose()

        Dim CloseWindowScript As String = "<script language='javascript'>" + "window.close();</script>"
        Page.ClientScript.RegisterStartupScript(Me.GetType(), "CloseWindow", CloseWindowScript, False)
    End Sub

This doesn't work...it clears out the Crystal Report but the window is still open with my buttons at the top hit close again nothing???

Thanks,
Mark
0
Comment
Question by:smithmrk
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
10 Comments
 
LVL 101

Expert Comment

by:mlmcc
ID: 39219830
Are you saying when you close the Crystal window you want the app the terminate or that the close button on the app no longer works?

mlmcc
0
 

Author Comment

by:smithmrk
ID: 39219846
See attached PDF with screen shots!

Mark
ReportRuns.pdf
0
 
LVL 26

Expert Comment

by:Shaun Kline
ID: 39219848
If all you need to do is close the window when the button is clicked, do not use code behind. Add your javascript to the button's client-side onclick event:
<button>.Attributes.Add("onclick", "window.close();")
0
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 
LVL 101

Expert Comment

by:mlmcc
ID: 39219851
Are you clicking the close button shown or the close/X in the report window?

mlmcc
0
 

Author Comment

by:smithmrk
ID: 39219855
Close Button
If I click the X then YES the window disappears...I want the same affect with the Close Button.

Mark
0
 
LVL 1

Expert Comment

by:xFDSx
ID: 39219875
Remove the disposes.... or move them below last line...
Replace false at end with true...
Page.ClientScript.RegisterStartupScript(Me.GetType(), "CloseWindow", CloseWindowScript, False)

Oh and your closewindowscript just needs to be "Window.Close()"
0
 

Author Comment

by:smithmrk
ID: 39219883
Nope same results!

Mark
0
 

Accepted Solution

by:
smithmrk earned 0 total points
ID: 39220171
OK, after about 6 hours of working on this taking your suggestions and google...I figured it out!

Instead of Page.ClientScript.RegisterStartupScript
I needed this:

ScriptManager.RegisterStartupScript(Me, Me.GetType(), "CloseWindow", "window.close();", True)

ScriptManager NOT Page.ClientScript.RegisterStartupScript!

Finally!!!

Thanks for you help!
Mark
0
 

Author Comment

by:smithmrk
ID: 39220182
Correction...I needed to have a Javascript Function on the page and call it using the ScriptManager:

Call:
ScriptManager.RegisterStartupScript(Me, Me.GetType(), "CloseWindow", "closeWindow();", True)

Function:
function closeWindow()
{
     window.close();
}
0
 

Author Closing Comment

by:smithmrk
ID: 39232749
Figured it out on my own!

Mark
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Creating an analog clock UserControl seems fairly straight forward.  It is, after all, essentially just a circle with several lines in it!  Two common approaches for rendering an analog clock typically involve either manually calculating points with…
Introduction This article shows how to use the open source plupload control to upload multiple images. The images are resized on the client side before uploading and the upload is done in chunks. Background I had to provide a way for user…
NetCrunch network monitor is a highly extensive platform for network monitoring and alert generation. In this video you'll see a live demo of NetCrunch with most notable features explained in a walk-through manner. You'll also get to know the philos…
In this video, Percona Solutions Engineer Barrett Chambers discusses some of the basic syntax differences between MySQL and MongoDB. To learn more check out our webinar on MongoDB administration for MySQL DBA: https://www.percona.com/resources/we…
Suggested Courses

764 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