Avatar of hannsmedia
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?

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

Open in new window


GetAdvDetailWS.aspx
<%@ 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">
    <title>GetAdvDetailWS</title>
</head>
<body>
    <form id="form1" runat="server">
    <div>
    <%
        Dim custID As String = Request("custID")
        Dim successLink As String = Request("successLink")
       
        Call GetAdvDetailWS(custID, successLink)
    %>
    
    </div>
    </form>
</body>
</html>

Open in new window


GetAdvDetailWS.aspx.vb
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.Redirect("http://google.com")
        Else
            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
hannsmedia

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)
hannsmedia

ASKER
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'.
ASKER CERTIFIED SOLUTION
hannsmedia

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
or
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
hannsmedia

ASKER
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