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

AngularJS: Enhancing User Experience by Preserving View State and Setup through Routes

Is it possible in a single page application to switch back and forth between AngularJS routes while maintaining the same state? Traditionally, this would involve binding data in a parent scope. However, for views with extensive graphical elements, this me ...

False return - Inoperative link - Scroll option

I have a JavaScript drop-down menu that is functioning correctly, but when I click on one of the links in the dropdown, the link does not work. I suspect it has something to do with my "return false/true" setup. Here's my JavaScript code: function d ...

Issue with Caching during Javascript Minification

I Have ASP.Net MVC 3 App. Utilizing YUICompressor.Net for compressing Javascript and CSS files post build with MSBuild. The minimized javascript file is named JSMin.js and the CSS file is CssMin.css. In my master page, I reference these files as shown bel ...

Update the input type on the fly

Hey there, I've got a bit of an unusual question. I'm looking to create a form with fields that vary for each user, like a text input or a checkbox. I attempted using Angular to achieve this: <div ng-controller="myCtrl" ng-repeat="x in prova" ...

What methods are available for updating the href color of an element using the DOM?

I am looking to update the color of a tab (Mathematics-tab) based on the value of 'aria-selected' changing to true in Bootstrap. I have multiple tabs, including one for mathematics, and I want to visually differentiate between selected and unsele ...

Utilizing Template Styling for Iterating through Lists in Vue.js

I would like the output format to display one player value followed by one monster value, repeating this pattern for each pair of values. new Vue({ el: app, data: { output: { player: [1, 5, 61, 98, 15, 315, 154, 65], monster: [2,14, ...

The requested `GLIBC_2.28' version required by node cannot be located, leading to an inability to amplify the version

While there were numerous questions about this topic, I am specifically seeking solutions for amplify. Below are the logs from my amplify build: 2024-01-14T16:14:17.626Z [INFO]: # Cloning repository: <a href="/cdn-cgi/l/email-protection" class="__cf_em ...

Transform an array of Boolean values into a string array containing only the values that are true

Suppose we have an object like the following: likedFoods:{ pizza:true, pasta:false, steak:true, salad:false } We want to filter out the false values and convert it into a string array as shown below: compiledLikedFoods = ["pizza", "steak"] Is t ...

What is the best way to match the minimum height of one div to the height of another div?

I need to dynamically set the minimum height of #wrapper equal to the height of #sidebar, but the height of #sidebar is not fixed. Here is my attempt at achieving this with JavaScript: var sidebarHeight = jQuery('#sidebar').height; jQuery(&apos ...

The function onKeyDown is not working properly

I am currently working with a Material-UI Table and have the following code: <Table onKeyDown={event => console.log(event)}> <TableBody> ... </TableBody> </Table> Despite having the onKeyDown event listener set up, I a ...

What is the impact of a floated element on vertical spacing?

I have come across an article discussing the usage of CSS, but I am puzzled as to why image number four is not positioned below image number one. Instead, it appears below image number three. Can someone please explain this to me? Here is the HTML code sni ...

Is it possible for me to send transactions asynchronously using polkadot-js?

After thoroughly going through the official documentation, I stumbled upon a page discussing how to transfer using polkadot-js const transfer = api.tx.balances.transfer(BOB, 12345); const hash = await transfer.signAndSend(alice); I am curious if it' ...

What is the best way to create a seamless Asynchronous loop?

Adhering to the traditional REST standards, I have divided my resources into separate endpoints and calls. The primary focus here revolves around two main objects: List and Item (with a list containing items as well as additional associated data). For ins ...

Reliable selection menu for changing fields

Can someone help me with this coding issue? I am attempting to create a dependent dropdown menu where selecting a category will also display relevant equipment. However, in my current setup, only the category field is functioning properly. When I try to a ...

Newbie Inquiry Renewed: What is the best way to convert this into a functional hyperlink that maintains the data received from the ID tag?

I have no prior training etc. If you are not willing to help, please refrain from responding as I am simply trying to learn here. <a id="player-web-Link">View in Depth Stats</a> This code snippet loads the following image: https://i.stack.i ...

The onKeyUp event is not functioning as expected in React, unlike the onChange event

For a React coding challenge, I am required to update a value onKeyUp instead of onChange. However, after changing it to onKeyUp, my fields are not updating and I cannot type anything into the textarea. class MarkdownApp extends React.Component { constr ...

Facing a problem with the carousel in Angular 6

I am currently working with Angular 6 and I have a topAdvertisementList[] that is supposed to return 2 records to be displayed in my carousel with a fixed image, but for some reason, only one record is showing up in the carousel! I suspect there might be a ...

Step-by-step guide for implementing a scroll event on FancyBox

I am facing an issue with a large fancybox popup that contains a scroll function. I need to find a way to attach an event to this fancybox popup when scrolling. I have tried several different events, such as: $('.fancybox-inner').off("scrol ...

Navigational(Probe) Pagination and Csharp MongoDB Interface

I am exploring the option of implementing keyset/seek pagination for my MongoDB results using the C# MongoDB Driver, specifically avoiding offset pagination. In my database, I have a variety of tags with the following structure: { "_id" ...

Is it possible to utilize TypeScript code to dynamically update the JSON filter with variable values?

I am dealing with a JSON filter in which the value for firmwareversion needs to be replaced with a dynamic value. Here's how I've set it up: //JSON filter this.comX200FilterValue = '{ "deviceType": "ComX", "firmwareV ...