``After inserting data, remember to close the popup window and refresh the datagrid to display the updated

I am currently working with asp.net and have encountered an issue with a popup window. On my main page, I have a button that, when clicked, triggers the appearance of a popup window. This popup window contains two text fields and two buttons - one for submitting data and the other for closing the window.

When I click the cancel button, the popup window closes as expected. However, if I enter information into the text fields and click submit, the data is successfully inserted into the server but the popup window remains open. This prevents me from properly interacting with the page and I have to manually refresh the page to proceed.

I am seeking advice on how to automatically close the popup window in asp.net after data has been successfully inserted into the database.

Below is the code snippet used to display and hide the popup window:

<script language="javascript" type="text/javascript" src="../JS/jquery.min.js"></script>
<script language="javascript" type="text/javascript" src="../JS/modalpopup.js"></script>
<style>
  *html #dvPopup {
    top: expression(eval(document.documentElement.scrollTop)) !important;
  }
</style>
<table style="background-color: transparent" cellspacing="0" cellpadding="0" width="100%">
  <tr>
    <td class="heder" valign="middle" height="30" style="padding-left: 10px" colspan="2">
      <img height="13" hspace="5" src="../images/arrow.gif" width="13" align="absMiddle">
      &nbsp;<strong>Destination Management</strong>&nbsp;<br />
    </td>
  </tr>
  <tr>
    <td>Destination Name :
      <asp:TextBox ID="txtDestinationName" runat="server"></asp:TextBox>
      <asp:RequiredFieldValidator ID="RequiredFieldValidator1" runat="server"
        ErrorMessage="*" ControlToValidate="txtDestinationName">
      </asp:RequiredFieldValidator>
    </td>
    <td>
      <asp:Button ID="btnAdd" runat="server" CssClass="BUTTON" Text="Add"
        Width="70px" OnClick="btnAdd_Click" >
      </asp:Button>&nbsp;
      <input type="button" id="Button1" value="Close"
        onclick="HideModalPopup('dvPopup'); return false;" />
    </td>
  </tr>
</table>

Any advice or suggestions would be greatly appreciated.

Answer №1

It's actually quite easy to implement on your server side when handling the click event.

Simply include a script resource like HideModalPopup('dvPopup'); on your page.

For more information, you can refer to this helpful resource.

Answer №2

The reason why the popup window is not closing after submission is due to the fact that it is not being triggered by the submit button

You must activate it once the data has been successfully sent to the server

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

Trouble with Vue 3 watch not persisting after page refresh

Attempting to create a Vue application that supports two languages, utilizing local storage and store to store the selected language. Initially, everything appears to be functioning correctly. After the user logs in, the default language is displayed in b ...

Having trouble parsing asynchronous script with cheerio parser

Utilizing cheerio for web crawling poses a challenge when encountering websites with asynchronous scripts. When attempting to extract all the scripts from such websites, they are often missed in the process. Here is an example of the code I am currently us ...

Looking for a way to execute code exclusively when the 'other' option is chosen? Let's tackle this challenge with Javascript and swig

I am looking to utilize swig (my chosen templating engine) for incorporating JavaScript code that will only display when the user selects the 'other' option from the select menu. <div class="form-group"> <select class="custom-select"&g ...

Having trouble displaying the time in the middle square when pressing TouchableOpacity in React Native?

Having trouble pressing the TouchableOpacity button as it's not responding, and even after pressing it, I need to access the time picker to select a specific time to display inside the square view in the center. Any suggestions on how to resolve this ...

Discovering useful data like metadata and subject matter through the utilization of either a URL or the webpage itself alongside JQUery

Imagine you have a URL and you want to display information related to that URL on your webpage, similar to how Facebook or LinkedIn does. You input a URL and the website data is retrieved for display. I am working on an application using JQuery and HTML ...

Leverage the power of openCv.js within your next.js projects

I am attempting to incorporate openCv.js into my next.js application a. I started the project with: npx create-next-app b. Next, I installed: $ yarn add @techstark/opencv-js c. Imported OpenCV with: import cv from "@techstark/opencv-js" d. Ho ...

Ways to loop through an array in a JSON object

Exploring methods of iterating through an array in json: $(document).ready(function(){ $('#wardno').change(function(){ //this code will execute whenever there is a change in the select with id country $("#wardname > ...

Tips for saving text box values in a grid while paging in ASP.NET

Hey, I've encountered an issue in grid view where after the page loads and I enter some values into a text box, those values disappear when I navigate to the next page. How can I ensure that these values are saved and retrieved in the grid view? I am ...

Set checkbox variable to undefined at all times

I am having trouble determining the state (True/False/null, etc.) of my "CSS-only" toggle switch. No matter what I try, I keep getting a null value. I'm not sure why this is happening, but it seems that the checkbox input is not functioning as expecte ...

How about starting a Node.js application with specific configurations?

Is there a way to develop a Node.js app that can be initiated with additional parameters? Here are a few examples: node myApp.js -nolog This command would initialize the app with the custom parameter noLog=true, preventing console logging. node myApp.js ...

What's preventing me from tapping on hyperlinks on my mobile device?

I'm currently working on a website (saulesinterjerai.lt) and everything seems to be functioning properly, except for the fact that on mobile devices, the links aren't clickable and instead navigates to other layers. How can I disable this behavio ...

What is the best way to incorporate sound into an asp.net web page?

I am trying to add sound effects to my webpage when a button is clicked. However, I keep encountering an error with the following code: SoundPlayer audio = new SoundPlayer(); audio.SoundLocation = "WindowsBalloon.wav"; //audio.Play(); audio.PlaySync(); T ...

Somehow, my array only manages to traverse exactly half of its elements

Something odd is happening with my input tag in the HTML file where only half of my array elements are being processed. The input collects numbers/letters and assigns a line of code, like this: let result = Object.fromEntries( Object.entries(answers2).m ...

Travis is checking to see if the undefined value is being

My experience with jasmine testing has been successful when done locally. However, I am encountering issues on Travis CI where all the API tests are returning undefined values. Here is an example: 4) Checking Server Status for GET /api/v1/orders - Expecte ...

Combining the Powers of Express.js and Kue.js

Currently, I am working on a personal project that involves processing tasks in the background. To achieve this, I need to establish communication between my Express and Kue frameworks. Here is a brief overview of my setup: My Express.js application forks ...

Enhance the visual appeal of Autodesk Forge Viewer by incorporating environmental textures

Is there a way to incorporate an environmental texture into Autodesk Forge Viewer v6.0? I know in Three.js you can apply a texture to the scene's background and environment, so how would I achieve this in APS viewer? I'm not looking for a skybox ...

Only the specified levels are included in the Object Cycle of System.Text.Json

I am facing an issue with self-referencing loops in my code due to the use of includes in my queries. For example: await context.Users.Include(x => x.Location).ToListAsync(); To address this problem, I could add the following line of code in my startu ...

Error: Unable to access the 'clearAsyncValidators' property as it is undefined when running Jest tests on an Angular component

Encountering an Error While Testing Components with Jest Here is my code block for onClickLogin() method: onClickLogin() { if(this.loginForm.valid) { this.api.getLoginData().subscribe(res => { const user = res.find(a => { ...

Ways to retrieve HTML tags from a website's DOM and shadowDOM

I am currently working on a project using NodeJS where I need to extract the HTML structure of multiple websites. However, I am facing some challenges with this task. My goal is to retrieve only the HTML structure of the document without any content. It is ...

Encountering issues during the transition to the updated react-native version 0.70 has posed a challenge for

Help! I encountered an error and need assistance fixing it. I've tried clearing my cache but that didn't work! The error is a TypeError: undefined is not a function in the JS engine Hermes. It also shows an Invariant Violation: Failed to call in ...