When the child page is closed, pass the value to the parent page (pass value from Child Window to parent window, when the child window is closing)

Source: Internet
Author: User
Q:

I have a modal dialog window that pops up to allow the user to enter line item Info (via a datalist ). when the user closes this dialog via an OK button I created, I am returning the total value of the line items to the parent form to be displayed. how can I pass this value if the user clicks the window close ('x') button instead of my OK? I tried adding <body onUnload = 'retvalue () '>, but this caused an issue with my DataGrid (whenever the 'edit' button was clicked, the dialog closed ). can I either disable the close button and force the user to click 'OK', or capture the click event on the close button to return the value.

A:

I have read the thread carefully, and based on my understanding, what you need is that, open a modal dialog window, for some user input, then, when user click the "OK" button, or click "X" to close, in your main page, you want get some message, which from user input, is right?

 

If so, as far as I can see, for your information, handle the onUnload Event is not seemly in your solution, whereas, There are too other ways can achieve that:

 

A.As far as I can see, "disable the X button" seems impossibility, but you can use a pop Div instead of the pop window, just refer to the following link:

Http://forums.asp.net/p/1264542/2372747.aspx#2372747

 

B.You can useModalpopup controlASP. NET Ajax Control Toolkit, easy and handle

The modalpopup extender allows a page to display content to the user in a "Modal" manner which prevents the user from interacting with the rest of the page.

Http://www.asp.net/AJAX/AjaxControlToolkit/Samples/ModalPopup/ModalPopup.aspx

 

C.Some open-source demo, can meet your needs, please refer to the following link:

Http://www.dynamicdrive.com/dynamicindex8/dhtmlwindow/

 

D.Handle the "X" button click event, but it seems not work in Firefox

 
 

< Script Language = " Javascript " >
<! --
Function Window. onbeforeunload ()
{
If (Event. clientx > Document. Body. clientwidth && Event. clienty < 0   | Event. altkey)
{
Window. event. returnvalue="Are you sure to exit?";
}
}
// -->
< / SCRIPT>

Otherwise, I suggest you to add a confirm dialog when your onbeforeunload event, to remind user click the "OK" button.

 

If I 've misunderstood your problem, feel free to reply. 

 

Thanks.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.