Avatar of hannsmedia
Flag 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" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" >
<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

Visual Basic.NET.NET Programming

Avatar of undefined
Last Comment

8/22/2022 - Mon
Kiran Sonawane

Try like this..

replace line number 9 in GetAdvDetailWS.aspx.vb with

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

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'.

Log in or sign up to see answer
Become an EE member today7-DAY FREE TRIAL
Members can start a 7-Day Free trial then enjoy unlimited access to the platform
Sign up - Free for 7 days
Learn why we charge membership fees
We get it - no one likes a content blocker. Take one extra minute and find out why we block content.
Not exactly the question you had in mind?
Sign up for an EE membership and get your own personalized solution. With an EE membership, you can ask unlimited troubleshooting, research, or opinion questions.
ask a question

The best solution I have found and it close browser without any prompt.
Experts Exchange is like having an extremely knowledgeable team sitting and waiting for your call. Couldn't do my job half as well as I do without it!
James Murphy