Closing a window from vb back end code

peterdoherty

Well-known member
Joined
Feb 24, 2003
Messages
49
Hi there does anyone know how to close a pop up from the back end vb code (ie the .aspx.vb code file) of a webform??

Cheers

Peter
 
Have the code-behind output the appropriate JavaScript, window.close(), to the page. The location to output the JavaScript all depends on what youre trying to accomplish.
 
Well what I am doing is opening a window with code executing behind it when it opens up. I would like to close the window once this code has finshed executing. Below is the .aspx.vb

Code:
Public Class DeleteAppointment
    Inherits System.Web.UI.Page
    Dim iAppointmentID As Integer
    Dim sAppointmentType As String
#Region " Web Form Designer Generated Code "

    This call is required by the Web Form Designer.
    <System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()

    End Sub

    Private Sub Page_Init(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Init
        CODEGEN: This method call is required by the Web Form Designer
        Do not modify it using the code editor.
        InitializeComponent()
    End Sub

#End Region

    Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        Put user code to initialize the page here
        iAppointmentID = Page.Request.QueryString("Appointment_ID")
        sAppointmentType = Page.Request.QueryString("Type")
        DeleteAppointment()
**** I WOULD LIKE TO CLOSE THE WINDOW HERE *********
    End Sub
    Private Sub DeleteAppointment()
        Dim oDBHandler As New DBHandler()
        Dim sSql As String
        sSql = "Delete from [" & sAppointmentType & "] where appointment_id =" & iAppointmentID
        If oDBHandler.Connect = True Then
            If oDBHandler.ExecuteSQLCommand(sSql) = False Then
                error
            End If
            oDBHandler.EndConnection()
        Else
            error connecting
        End If
        oDBHandler = Nothing
    End Sub
End Class
 
I dont understand why youd want to do things like this, but I dont really need to know, do I? :)

Forget about the code-behind and add the following to the ASP.NET page itself:

Code:
<html>
    <head>
        <title>Demo</title>
    </head>
    <body onload="window.close()">
    </body>
</html>
 
cheers. Thats worked a treat!

I would explain exactly what im doing but i dont have the time unfortuatly
 
Back
Top