Programmatically close aspx page from code behind

前端 未结 13 2109
佛祖请我去吃肉
佛祖请我去吃肉 2020-11-29 05:05

What is the best way to close an ASPX page from the code-behind?

I have a button event handler that I want to close the page after the user has clicked an ASP.NET

13条回答
  •  轻奢々
    轻奢々 (楼主)
    2020-11-29 05:46

    A postback is the process of re-loading a page, so if you want the page to close after the postback then you need to set your window.close() javascript to run with the browser's onload event during that postback, normally done using the ClientScript.RegisterStartupScript() function.

    But are you sure this is what you want to do? Closing pages tends to piss off users.

提交回复
热议问题