从code编程背后接近aspx页面 [英] Programmatically close aspx page from code behind
问题描述
什么是从code-背后关闭一个ASPX页面的最佳方式?
What is the best way to close an ASPX page from the code-behind?
我有我想要的用户点击一个按钮,ASP.NET页面上后关闭网页上的按钮事件处理程序。我试图以编程方式添加包含 window.close()的
命令的的OnClientClick
事件关闭JavaScript方法该网页,但它不工作。该按钮也是一个 ASP:AsyncPostBoskTrigger
一个AJAX更新面板
I have a button event handler that I want to close the page after the user has clicked an ASP.NET button on the page. I have tried to programmatically add a JavaScript method that contains a window.close()
command to the OnClientClick
event to close the page but it does not work. The button is also a asp:AsyncPostBoskTrigger
for an AJAX Update Panel.
应用程序使用的.NET Framework 3.5。
The application uses .NET Framework 3.5.
推荐答案
更新:我已经采取了一切你的输入,并用以下解决方案提出了:
UPDATE: I have taken all of your input and came up with the following solution:
在code背后:
protected void Page_Load(object sender, EventArgs e)
{
Page.ClientScript.RegisterOnSubmitStatement(typeof(Page), "closePage", "window.onunload = CloseWindow();");
}
在aspx页面:
function CloseWindow() {
window.close();
}
这篇关于从code编程背后接近aspx页面的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!