本文介绍了如何在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#中关闭带有警报消息的浏览器选项卡
发布评论