Steps for programmatically closing a Dialog Window in a showmodeldialog window

When opening the window, I follow this approach:

 var MyArgs = new Array(ParmA, ParmB, ParmC, ParmD, ParmE, ParmF);
var leftpost = getWindow_TotalWidth() - 1000 - 100;
var WinSettings1 = "dialogHeight:580px; dialogWidth:950px;edge:Raised; center:Yes; resizable:No; status: No;dialogLeft:" + leftpost + ";dialogTop:253px";
var MyArgs = window.showModalDialog("../Accounts/LedgerAdd.aspx?LedgerCode=" + MyArgs[1].toString().split("~")[0] + "&Popup=1", MyArgs, WinSettings1);

However, closing the window based on a condition has proven to be more challenging. Various methods were attempted such as:

  If Not Convert.ToDecimal(HidOpeningBalance.Value) = Convert.ToDecimal(TxtOpeningBalance.Text) Then
            Dim LedgerID As Integer = Request.QueryString("LedgerCode")
            Dim dtTransactionCount As DataTable = Grid.GetDataTable("sp_checkForAnyTransaction", LedgerID)
            If dtTransactionCount.Rows.Count > 0 Then
                LblError.Text = "You can not change Opening Balance after transactions made on this ledger."
                Exit Sub
            Else
                Call FnUpdate()
                Page.ClientScript.RegisterStartupScript([GetType](), "Javascript", "javascript:CloseWindow();", True)

            End If
        Else
            LblError.Text = ""
            Call FnUpdate()
            Page.ClientScript.RegisterStartupScript([GetType](), "Javascript", "javascript:window.close();", True)
            'Response.Write("<script language='javascript'>self.close();</script>")
            'Page.ClientScript.RegisterStartupScript([GetType](), "Javascript", "javascript:CloseWindow();", True)

        End If

The closeWindows function is defined as follows:

  function CloseWindow() {
        window.close();         
    }

While calling the function on onClientClick event successfully closes the popup, attempting to close it from code behind presents challenges. Multiple approaches were tested and commented in my code but none resulted in the desired closing of the window.

Answer №1

Kindly assess the solution provided in the following link: as it outlines the following solution:

<base target="_self">

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Discovering Unconventional Columns Through Sharepoint REST Api Filtration

I am working on recreating SharePoint's front end in my app and want to add columns to my table just like a user would in SP. The challenge I am facing is determining which columns were custom generated by the user rather than standard ones. Although ...

Reopen a Kendo UI dialog

Currently, I am utilizing Kendo UI, and my goal is to display a modal dialog when a button is clicked. The issue I am facing is that it works perfectly the first time around. However, upon closing the dialog and attempting to reopen it by clicking the butt ...

Enhancing a specific element in a view using Node.js alongside Express and EJS

My goal is to modify value2 on the server side and update the view accordingly. The question at hand is: How can I efficiently refresh the view with only the new value2? Server: var express = require("express"); var app = express(); app.set('view ...

It appears that the Next.js environment variables are not defined

Upon setting up a fresh next.js project using npx create-next-app@latest and configuring some environment variables in the .env.local file, I encountered an error when attempting to run the server. "Failed to load env from .env.local TypeError: Cannot ...

Automatically selecting the map center while using the Drawing Manager feature for placing markers

My application utilizes the Google Drawing Library. When a user clicks on the Add New Marker Button, the Drawing Manager is activated allowing the user to generate a marker by clicking anywhere on the map. Subsequently, the following listener is executed: ...

Animating elements on a webpage can be achieved by using both

Is there a way to create an animation that moves objects based on button clicks? For example, when the "Monday" button is pressed, the object with the correct color will move down. If any other button like "Tuesday" is clicked, the previous object will mov ...

Creating Eye-Catching Images by Incorporating Image Overlays Using Just One Image

I'm facing a bit of a challenge here. I need to figure out how to overlay an image onto another image using just a single image tag. Specifically, I want to add a resize icon to the bottom right corner of an image to let users know they can resize it ...

Using Angular UI Router to Access $scope Beyond the Scope of the UI View

Looking for a way to access $scope outside the UI view in my todo app. The structure is simple, with three panels as shown in this design For the full code, visit here I need to access the to-do detail on the third panel using $rootScope, which currently ...

Expanding using CSS3 to ensure it doesn't take up previous space

Currently, I am working on an animation for my web application. More specifically, I am looking to scale certain elements using CSS3 with the scaleY(0.5) property. These elements are arranged in a vertical list, and I want to ensure that they do not take u ...

What distinguishes running rm -rf node_modules + npm i from using npm ci?

When using a Unix system and needing to clean out the node modules folder, is there any benefit or distinction between executing rm -rf node_modules followed by npm i as opposed to npm ci My understanding is that both yield the same outcome, but is th ...

Utilizing the reduce method to transform an array containing nested arrays into a different structure

I'm having trouble figuring out how to restructure the array below. I attempted to utilize the reduce function in JavaScript but unfortunately, I couldn't make it work. So far, this is the function I have come up with: var comb = [] var setEle ...

What methods can I leverage in VueJS to redirect users to a different page or URL?

I am new to JavaScript, so please excuse any mistakes in my code. I am working on a form that utilizes AWS SNS to send an email to my company with the data submitted through the form. The issue I'm facing is that there is no feedback for the user afte ...

How do I rearrange the order of a collection in Firestore using a reference that I already have?

Is there a method to maintain a reference of the same collection while altering the ordering using firestore? TLDR: I am looking to achieve similar functionality as demonstrated in: , but since my data is sourced from firestore, I am struggling to find th ...

Looking for assistance with arranging and managing several containers, buttons, and modals?

My goal is to create a grid of photos that, when hovered over, display a button that can be clicked to open a modal. I initially got one photo to work with this functionality, but as I added more photos and buttons, I encountered an issue where the first b ...

Obtain a custom token after next authentication through Google login

Utilizing next js, next auth, and a custom backend (flask), I have set up an API Endpoint secured with jwt token. In my next js frontend, I aim to retrieve this jwt token using the useSession hook to send requests to these API Endpoints. Everything functio ...

A step-by-step guide on accessing an API to check the status updates of ongoing API calls

I'm facing an issue with making two API calls concurrently. The goal is to have call X executed first, while Y should run in parallel and keep calling itself recursively until the X API resolves. Both calls should be initiated immediately upon clickin ...

Reposition the Column, Filter popover within the MUI Data Grid Pro

I am working with the MUI Data Grid Pro to showcase my data. By default, the Data Grid Pro exhibits the toolbar on the left side. Although I managed to shift the toolbar to the right side, the popovers and menus retained their position on the left. My inte ...

Encountered a runtime error in NgRx 7.4.0: "Uncaught TypeError: ctor is not a

I'm facing difficulties trying to figure out why I can't register my effects with NgRx version 7.4.0. Despite simplifying my effects class in search of a solution, I keep encountering the following error: main.79a79285b0ad5f8b4e8a.js:33529 Uncau ...

Unable to perform a default import in Angular 9 version

I made adjustments to tsconfig.json by adding the following properties: "esModuleInterop": true, "allowSyntheticDefaultImports": true, This was done in order to successfully import an npm package using import * as ms from "ms"; Despite these changes, I ...

Cookies in Node.js Express are not being incorporated

Currently, I am in the process of developing a nodejs application and facing an issue with defining cookies. Here is a snippet of the code that I am working with: var app = express(); app.set('port', process.env.PORT || 3000); app.set('vie ...