在 aspx page1 中我有一个按钮。我单击该按钮,它会打开一个在 aspx page2 中实现的 radwindow。在 radwindow 中,我输入一些数据并单击“保存”按钮。它调用服务器端方法,然后关闭 radwindow。关闭 radwindow 后,它应该触发 page1 的方法。如何实现这一目标?
从 page1 打开 radwindow 的代码:
function btnAddNewImage_click() {
debugger;
var hdn_PatientId = document.getElementById("<%=hdn_PatientId.ClientID %>").value;
var selectedEncounterId = document.getElementById("<%=hdn_EncounterId.ClientID %>").value;
var oWnd = radopen("../Admin/Encounter/PopUps/UploadImages.aspx?EncounterId=" + selectedEncounterId + "&PatientId=" + hdn_PatientId, "rwDialog");
oWnd.SetTitle("Upload Image");
oWnd.SetSize(600, 350);
oWnd.Center();
//oWnd.add_close("refreshGrid");
oWnd.OnClientClose = "refreshGrid"; // Not working
return false;
}
radwindow 关闭后触发的函数:
function refreshGrid(sender, eventArgs) {
debugger;
alert("in refreshgrid");
var selectedEncounterId = document.getElementById("<%=hdn_EncounterId.ClientID %>").value;
loadImagesProgressNotes(selectedEncounterId, "Current");
}
第2页关闭radwindow的代码
RadScriptManager.RegisterStartupScript(this, this.GetType(), "Alert", "javascript:returnToParent();", true);
function returnToParent() {
debugger;
//get a reference to the current RadWindow
var oWnd = GetRadWindow();
oWnd.close();
}
最佳答案
我尝试测试你的代码,但不能。我在示例中看到的是 radwindow 是以这种方式声明的,而不是像您尝试的那样动态声明。
<telerik:RadWindow RenderMode="Lightweight" runat="server"
ID="RadWindow1" OnClientClose="OnClientCloseHandler"
NavigateUrl="dialog-page.aspx" VisibleOnPageLoad="true">
</telerik:RadWindow>
我建议您查阅文档,那里有一些示例。
OnClientClose演示:
https://demos.telerik.com/aspnet-ajax/window/examples/clientsideevents/defaultcs.aspx
OnClientClose 文档:
关于javascript - 如何在关闭 radwindow 后调用客户端 JavaScript 函数,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38781959/