您的位置:首页 > 产品设计 > UI/UE

子页面关闭时传值给父页面(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
<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.
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: 
相关文章推荐