Link to home
Start Free TrialLog in
Avatar of hannsmedia
hannsmediaFlag for Singapore

asked on

How to close browser in aspx.vb page

Hi. I am having problem to close a browser. I will execute Schedule_AutoBill.vbs which then will open a browser and go to GetAdvDetailWS.aspx. How do I close the browser in my .aspx.vb file?

Set WshShell = WScript.CreateObject("WScript.Shell") 
RunWeb = WshShell.Run("http://nothern/ws/GetADvDetailWS/GetAdvDetailWS.aspx?custID=CU0&successLink=", 1) 

Open in new window

<%@ Page Language="VB" AutoEventWireup="false" CodeFile="GetAdvDetailWS.aspx.vb" Inherits="_Default" Debug="true" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "">

<html xmlns="" >
<head runat="server">
    <form id="form1" runat="server">
        Dim custID As String = Request("custID")
        Dim successLink As String = Request("successLink")
        Call GetAdvDetailWS(custID, successLink)

Open in new window

Imports System.Data
Imports System.Data.SqlClient
Partial Class _Default
    Inherits System.Web.UI.Page
    Sub GetAdvDetailWS(ByVal custIDList, ByVal successLink)
        If len(successLink) > 0 Then
            Response.Write("<script language='text/javascript'>window.close();</script>")
        End If
    End Sub

Open in new window

Avatar of Kiran Sonawane
Kiran Sonawane
Flag of India image

Try like this..

replace line number 9 in GetAdvDetailWS.aspx.vb with

 ScriptManager.RegisterStartupScript(Me, GetType(Page), UniqueID, "javascript:window.close();", True)
Avatar of hannsmedia


I tried and got a compilation error.

Compilation Error
Description: An error occurred during the compilation of a resource required to service this request. Please review the following specific error details and modify your source code appropriately.

Compiler Error Message: BC30390: 'System.Web.UI.Page.Private ReadOnly Property ScriptManager() As System.Web.UI.IScriptManager' is not accessible in this context because it is 'Private'.
Avatar of hannsmedia
Flag of Singapore image

Link to home
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
The best solution I have found and it close browser without any prompt.