ASP.NET 子窗口在每次回发时都会在新窗口上打开

标签 asp.net asp.net-2.0

我有一个带有网格的 asp.net 页面。在 RowDateBound 事件上

mybutton.Attributes.Add("onclick", "javascript:window.showModalDialog('some.aspx?ID="
                                                                    + mybutton.CommandArgument + 
                                                                    "','window.self','dialogWidth:800px; dialogHeight:800px;center:yes; status:yes; scroll:no; help:no');");

在 some.aspx 页面上,我有下拉菜单和执行回发的 asp.net 按钮。回发时,some.aspx 页面会在新窗口(浏览器)中再次打开。

如何防止这种情况发生?

感谢您的支持。

最佳答案

我以前在使用 ASP.NET 和 ModalDialog 时也遇到过这个问题。您需要做的就是设置 <base target="_self">标签在页面的头部。这听起来太简单了,不正确,但它为我解决了这个问题。

这让我很沮丧。

如果您需要任何帮助,请直接询问。

<html>
<head>
  <title>My Page</title>
  <base target="_self">
</head>
<body>
<!-- Your content -->
</body>
</html>

关于ASP.NET 子窗口在每次回发时都会在新窗口上打开,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7391080/

相关文章:

c# - Visual Studio 2015 不是语法高亮 Razor ,也不是 Intellisense

asp.net - AppPool 自行关闭

c# - 强制浏览器下载 PDF 文档而不是打开它

c# - 如何在一个项目的不同版本中包含第 3 方代码

asp.net - 有没有办法在不破坏 ASP.Net 回发的情况下修改查询字符串?

c# - 访问嵌套母版页代码中的顶级母版页属性

asp.net - 为什么没有代码的 ASP.Net 2.0 应用程序在首次运行时需要 2 分钟才能加载?

asp.net - 为什么设置 @Page masterPageFIle 时不隐含 @MasterType 指令?

c# - asp.net 中的线程 (C#)

asp.net - 为什么我的 ASP.NET 单点登录停止工作?