我想关闭 RadWindow并刷新父级:如何在服务器端执行此操作:
我有以下案例:
两页说:
父级.aspx :
<telerik:RadWindowManager ID="RadWindowManager1" runat="server" EnableViewState ="false">
</telerik:RadWindowManager>
和parent.cs
protected void OpenNewWindow(string url, int width, int height,int mode)
{
RadWindow newWindow = new RadWindow();
newWindow.NavigateUrl = url;
newWindow.VisibleOnPageLoad = true;
newWindow.KeepInScreenBounds = true;
if (width > 0)
{
newWindow.Width = width;
}
if (height > 0)
{
newWindow.Height = height;
}
newWindow.VisibleStatusbar = false;
if (mode == 0)
{
newWindow.DestroyOnClose = true;
newWindow.InitialBehaviors = WindowBehaviors.Maximize;
}
RadWindowManager1.Windows.Add(newWindow);
}
我在父页面上的某个 gridview 的行命令中调用此方法:
像这样:
OpenNewWindow("child.aspx", 0, 0,0);
现在我想在服务器端单击 child
页面上某个按钮的事件以关闭 rad 窗口并刷新父窗口如何执行此操作??
最佳答案
如您所说,您想从代码隐藏中关闭。因此,您可以从后面的代码呈现 Page.ClientScript.RegisterClientScriptBlock(GetType(), "CloseScript", "refreshParentPage()", true);
以刷新父级。
只需在子页面中添加以下代码和脚本即可。父页面中不需要代码。
<script>
function getRadWindow() {
var oWindow = null;
if (window.radWindow)
oWindow = window.radWindow;
else if (window.frameElement.radWindow)
oWindow = window.frameElement.radWindow;
return oWindow;
}
// Reload parent page
function refreshParentPage() {
getRadWindow().BrowserWindow.location.reload();
}
</script>
<asp:Button runat="server" Text="Close" ID="CloseButton"
OnClick="CloseButton_Click"/>
protected void CloseButton_Click(object sender, EventArgs e)
{
Page.ClientScript.RegisterClientScriptBlock(GetType(),
"CloseScript", "refreshParentPage()", true);
}
更新:
// Redirect page page to url
function redirectParentPage(url) {
getRadWindow().BrowserWindow.document.location.href = url;
}
// Code behind
Page.ClientScript.RegisterClientScriptBlock(GetType(),
"CloseScript", "redirectParentPage('Parent.aspx')", true);
关于c# - 如何在服务器端关闭radwindow并刷新父页面,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15640301/