admin管理员组文章数量:1401926
I have a popup window that closes when a Cancel button is clicked:
btnCancel.Attributes.Add("onclick", "window.close();");
but I want to use another button (Save) to insert to database, then close the window:
if( success )
{
closePopup();
}
The insert function will be in C#, not in JavaScript.
I have a popup window that closes when a Cancel button is clicked:
btnCancel.Attributes.Add("onclick", "window.close();");
but I want to use another button (Save) to insert to database, then close the window:
if( success )
{
closePopup();
}
The insert function will be in C#, not in JavaScript.
Share Improve this question edited Jan 20, 2023 at 18:01 double-beep 5,53719 gold badges40 silver badges49 bronze badges asked Mar 17, 2014 at 12:05 DevBassemDevBassem 331 gold badge2 silver badges7 bronze badges 2- Where is your code for opening a popup? – Murali Murugesan Commented Mar 17, 2014 at 12:17
- open code must be in the parent page. – DevBassem Commented Mar 17, 2014 at 13:22
2 Answers
Reset to default 3ScriptManager.RegisterStartupScript(this, this.GetType(), "onclick", "window.close()", true);
window.close()
will close the current window. If you want to close the opened window popup try following the below approach.
Assuming you are opening a popup with a reference like below (Parent.aspx)
var windowObjectReference;
var strWindowFeatures = "menubar=yes,location=yes,resizable=yes,scrollbars=yes,status=yes";
function openRequestedPopup() {
windowObjectReference = window.open("mypage", "Popup Page", strWindowFeatures);
}
For closing a popup (child.aspx)
btnCancel.Attributes.Add("onclick", "parent.closePopup();");
Then (parent.aspx)
function closePopup()
{
windowObjectReference.close();
}
Refer window.open
and window.close()
本文标签: javascriptClose popup window after inserting to databaseStack Overflow
版权声明:本文标题:javascript - Close popup window after inserting to database - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1744317419a2600331.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论