子页面关闭时传值给父页面(pass value from child window to parent window, when the child window is closing)
2008-07-08 11:42
615 查看
问:
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.
答:
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 many 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 use ModalPopup control of ASP.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
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.
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.
答:
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 many 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 use ModalPopup control of ASP.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() //--> </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.
相关文章推荐
- Pass value from child popup window to parent page window using JavaScript--reference
- How to pass value from Child window to Parent Window
- Refresh parent window from child window without having to press the refresh button
- Resolution to the record count increasing of the file exported from DB when ‘0A’ is included in it
- IE 8 HTML Parsing Error: Unable to modify the parent container element before the child element is closed (KB927917)
- 【报错】IE 8 HTML Parsing Error:Unable to modify the parent container element before the child element is closed
- Message: HTML Parsing Error: Unable to modify the parent container element before the child element is closed (KB927917)
- javascript错误解决:Unable to modify the parent container element before the child element is closed
- 0x80091007 (The hash value is not correct) error when trying to deploy Windows 7 with SCCM OSD
- PostBack the form when a value is selected from the results returned by autocomplete extender
- XP下的IE8 错误:HTML Parsing Error: Unable to modify the parent container element before the child element is closed
- IE8 中"HTML Parsing Error:Unable to modify the parent container element before the child element is c
- How to pass the value to the function when clicking on the UIButton
- IE 8 HTML Parsing Error: Unable to modify the parent container element before the child element is closed (KB927917)
- IE8 下 HTML Parsing Error: Unable to modify the parent container element before the child element is closed (KB927917)
- 怎么修改字体粗细The valid value range is from -1.0 to 1.0
- HTML Parsing Error: Unable to modify the parent container element before the child element is closed
- IE 8 HTML Parsing Error: Unable to modify the parent container element before the child element is c
- HTML Parsing Error: Unable to modify the parent container element before the child element is closed (KB927917)
- HTML Parsing Error: Unable to modify the parent container element before the child element is closed