如何在c#中关闭带有警报消息的浏览器选项卡

编程入门 行业动态 更新时间:2024-10-24 06:33:24
本文介绍了如何在c#中关闭带有警报消息的浏览器选项卡的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我一直尝试使用下面的代码来执行,但是消息框没有显示,而且tab也没有关闭。

I have been trying with below code its getting execute but messagebox not displaying and tab also not getting close.

ScriptManager.RegisterStartupScript(this, this.GetType(), "Messagebox", "alert('Record Deleted successfully.Note: This tab is now getting close');", true);

所以我只是从上面的代码中删除'alert'代码,然后执行并关闭选项卡。但是我也想显示通知消息框怎么样?

so i just remove the 'alert' code from above code then its getting execute and getting close the tab. But I also want to display notification message box so how?

ScriptManager.RegisterStartupScript(this, this.GetType(), "Messagebox", "window.close();", true);

推荐答案

试试这个 Try this <script language="JavaScript" type="text/javascript"> window.onbeforeunload = confirmExit; function confirmExit() { return "Are you sure you want to exit this page?"; } </script>

Hi, ScriptManager.RegisterStartupScript(this,GetType(),"showalert","alert('Only alert Message');",true);

参考:Asp使用javascript显示来自代码的警报消息

更多推荐

如何在c#中关闭带有警报消息的浏览器选项卡

本文发布于:2023-11-27 21:15:19,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1639628.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:警报   选项卡   浏览器   消息   如何在

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!