我有一个带有网格的 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/