Sascha was at wit's end. "It's a fundamental underpinning of the web! Server-side code cannot interact with the user's web browser and tell it to close the window. You have to do it in JavaScript!"

"Okay," Sascha's coworker smiled wryly, "not only can it be done, but I've done it! How's that for your 'fundamental underpinning'?"

"Fine," he conceded, "just show me how you closed the web browser window without using JavaScript!"

The coworker quickly pulled up an ASP.NET code-behind file and scrolled to the following function, which was called by a button handler.

    Private Sub closePage(ByRef page As System.Web.UI.Page)
        Dim s As String
        s = "<SCRIPT LANGUAGE='JavaScript'>" & vbCrLf
        s &= "<!--" & vbCrLf
        s &= "window.close();" & vbCrLf
        s &= "//-->" & vbCrLf
        s &= " </SCRIPT>"
        page.RegisterClientScriptBlock("tjsClosePage", s)
    End Sub

"Well," Sascha said, "congratulations."

[Advertisement] BuildMaster allows you to create a self-service release management platform that allows different teams to manage their applications. Explore how!