ASP.NET child window opens up on a new window on every post back

风格不统一 提交于 2019-12-12 16:18:34

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!