问题
I have an asp.net page with a grid. On RowDateBound event
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');");
on some.aspx page I have dropdowns and asp.net button that does a postback.On postback the some.aspx page opens again in a new window (Browser).
How to prevent this?
I appreciate your support.
回答1:
I've had this problem before with ASP.NET and a ModalDialog. What you need to do is set the <base target="_self"> tag in the head of the page. It sounds too simple to be correct but it's what fixed it for me.
This frustrated me quite a bit.
If you need any help with this, just ask.
<html>
<head>
<title>My Page</title>
<base target="_self">
</head>
<body>
<!-- Your content -->
</body>
</html>
回答2:
You can place a return false; behind the link / button to stop the post back from happening.
来源:https://stackoverflow.com/questions/7391080/asp-net-child-window-opens-up-on-a-new-window-on-every-post-back