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?

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

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

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
Avatar of hannsmedia
hannsmedia
Flag of Singapore image

Link to home
membership
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.