gpt4 book ai didi

c# - 如何关闭其子窗口的父窗口?

转载 作者:可可西里 更新时间:2023-11-01 07:45:39 26 4
gpt4 key购买 nike

我有以下情况:

我的页面上有一个 GridView :

page1.aspx

我通过 rad window 中的那个 gridview 打开另一个页面 (page2.aspx)然后,通过 page2.aspx 上的一些按钮,我也在 rad 窗口 中打开最后一页 (page3.aspx)。

所有这些步骤都是通过服务器端代码执行的:


 protected void OpenNewWindow(string url, int width, int height, int mode)
{
RadWindow newWindow = new RadWindow();
newWindow.NavigateUrl = url;
newWindow.VisibleOnPageLoad = true;
newWindow.KeepInScreenBounds = true;
newWindow.Skin = "Metro";
if (width > 0)
{
newWindow.Width = width;


}
if (height > 0)
{
newWindow.Height = height;
}
newWindow.VisibleStatusbar = false;
if (mode == 0)
{
{

}
//newWindow.OnClientClose = "OnChildWindowClosed";
newWindow.DestroyOnClose = true;
newWindow.InitialBehaviors = WindowBehaviors.Maximize;
}
RadWindowManager1.Windows.Add(newWindow);
}

我想做的是:

当单击我的 (page3.aspx) 上的特定按钮时,关闭它及其父级 page2.aspx

如何做到这一点(服务器端)?

我试试这个:但它只是关闭子 page3.aspx 我也想关闭父 page2.aspx ?!


  protected void Button1_Click(object sender, EventArgs e)
{
((RadAjaxManager)this.Parent.FindControl("RadAjaxManager1")).ResponseScripts.Add("CloseModal();");

RadAjaxManager1.ResponseScripts.Add("CloseModal();");
}

最佳答案

protected void Button1_Click(object sender, EventArgs e)
{
((RadAjaxManager)this.Parent.FindControl("RadAjaxManager1")).ResponseScripts.Add("CloseModal();");

RadAjaxManager1.ResponseScripts.Add("CloseModal();");
}

如果 CloseModal() 事件正确触发,您应该能够在其中调用 window.close()。 RadWindows 仅存在于父窗口的上下文中,因此您仍然应该能够调用 window.close(),这将关闭每个打开的窗口。

编辑:虽然有点跑题,this link来自 Telerik 向您展示了如何从 RadWindow 获取父窗口的句柄。然后你可以在客户端调用close方法关闭浏览器窗口(page1.aspx),这将关闭所有后续的RadWindows。

来自 this link :

The main difference between RadWindow and browser's popup is that just like any other DHTML element, RadWindow exists only in the context of the page in which it is created. It cannot leave the boundaries of the browser window.

关于c# - 如何关闭其子窗口的父窗口?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15684522/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com