[英]Is there a way to get the response from a user when they click on the pop up message created when they close the window?
So I have a Silverlight project and in this Silverlight project I have a C# file where in one of the methods I use the following code to call a Javascript function: 所以我有一个Silverlight项目,在这个Silverlight项目中,我有一个C#文件,在其中一种方法中,我使用以下代码来调用Javascript函数:
HtmlPage.Window.Invoke("closeApplication");
The closeApplication function is as follows: closeApplication函数如下:
function closeApplication()
{
window.close();
}
This produces the pop message that says: 这将产生弹出消息,内容为:
The webpage you are viewing is trying to close the window. 您正在查看的网页正在尝试关闭窗口。
Do you want to close this Window? 您要关闭此窗口吗?
Yes No 是否
I want to know if there is a way to get the users response because if it's no. 我想知道是否有一种方法可以得到用户的响应,因为否。 In my c# file after I call the HtmlPage.Window.Invoke("closeApplication");
在调用HtmlPage.Window.Invoke(“ closeApplication”);之后,在我的c#文件中 function, I want to call a different method in that c# file.
函数,我想在该C#文件中调用其他方法。
Just cancel event close: 只需取消活动关闭:
Try this: 尝试这个:
MessageBoxResult result =
MessageBox.Show(
msg,
"Data App",
MessageBoxButton.YesNo,
MessageBoxImage.Warning);
if (result == MessageBoxResult.No)
{
// If user doesn't want to close, cancel closure
e.Cancel = true;
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.