简体   繁体   English

当用户单击关闭窗口时创建的弹出消息时,是否可以从用户那里获得响应?

[英]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.

相关问题 窗体关闭弹出 window 点击任意位置 - Form close pop up window on click anywhere 用户单击以关闭消息窗口时发生的事件 - Event when user clicks to close message window 当用户单击Visual Studio表单窗口内的任何位置时,如何弹出消息框? - How to pop up a message box when user clicks anywhere within the form window in Visual Studio? 弹出的用户控件在创建时无法正确呈现 - pop up user control not rendering correctly when created 单击ASP日历日期后如何显示弹出窗口? - How to show the Pop up from when click theASP calender date? 单击动态创建的链接按钮时如何生成一个弹出的aspx窗口? - how to generate a pop up aspx window when clicking on the dynamically created link button? 从警报弹出获取响应 - Get response from alert pop up 我如何关闭从另一个用户控件的按钮中弹出的用户控件,单击WPF中的事件 - How i can Close User Control which were open in pop up from another User Control's button click Event in WPF 当用户再次打开弹出窗口时,如何清除asp:TextBox的文本? - How to clear the text of asp:TextBox when user again open the pop up window? 单击某些按钮时弹出弹出拒绝访问消息,具体取决于哪个用户已登录 - Pop up access denied message when certain button is clicked depending on which user has logged in
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM