當你打電話給你的RadWindow時,確保設置了OnClientClose
事件。如果您是使用代碼隱藏您的RadWindow:
RadWindow newWindow = new RadWindow();
newWindow.OnClientClose = "onRadWindowClosed";
...
如果你是通過JavaScript打開你RadWindow,您可以使用add_close()方法:
...
getRadWindow().add_close('onRadWindowClosed');
...
在這兩種情況下,你需要創建調用頁面上的一個新的事件處理程序腳本的OnClientClose事件:
function onRadWindowClosed(sender, eventArgs) {
var returnValue = eventArgs.get_argument();
if (returnValue != null) {
if (returnValue == "continue") {
// Continue doing work
}
else {
// Throw an error
}
}
}
在您WUC,在btnContinue
單擊事件:
protected void btnContinue_Click(object sender, EventArgs e)
{
Page.ClientScript.RegisterClientScriptBlock(GetType(), "closeScript", "getRadWindow().close('continue');", true);
}
此功能用於兩個頁面上:
function getRadWindow() {
var oWindow = null;
if (window.radWindow)
oWindow = window.radWindow;
else if (window.frameElement.radWindow)
oWindow = window.frameElement.radWindow;
return oWindow;
}
更新到現有的應答
您的呼叫頁面,添加一個函數來獲取RadAjaxManager(假設你已經有了這一頁。如果沒有,你需要一個):
function get_ajaxManager() {
return $find("<%= Telerik.Web.UI.RadAjaxManager.GetCurrent(this.Page).ClientID %>");
}
修改您的OnClosed javascript函數(從調用頁面):
function onRadWindowClosed(sender, eventArgs) {
var returnValue = eventArgs.get_argument();
if (returnValue != null) {
if (returnValue == "continue") {
// This call will invoke a server side event
get_ajaxManager().ajaxRequest("continue~");
}
}
}
在您的代碼隱藏,處理服務器端事件得到所謂:
protected void RadAjaxManager1_Request(object source, Telerik.Web.UI.AjaxRequestEventArgs e)
{
try
{
if (e.Argument.Trim().Length == 0)
{
// Show a message when debugging, otherwise return
return;
}
string argument = (e.Argument);
String[] stringArray = argument.Split('~');
switch (stringArray[0])
{
case "continue":
// Continue performing your action or call a specific method
ServerSideMethodCall();
break;
}
}
catch (Exception ex)
{
RadAjaxManager.GetCurrent(this.Page).Alert("Unable to complete operation at this time: " + ex.Message);
}
}
正如前面提到的,你需要一個RadAjaxManager頁面上,如果你不已經有一個,和你需要的AjaxRequest處理器配合它。
<telerik:RadAjaxManager runat="server" ID="RadAjaxManager1" OnAjaxRequest="RadAjaxManager1_Request"></telerik:RadAjaxManager>
對不起,冗長的回答。讓我知道,如果那得到你所需要的。
這正是我所需要的,我只是遇到了問題,我放在調用WUC的頁面上的WebMethod沒有從onRadWindowClosed javascript函數中被解僱。 – razp26
我已經更新了我的答案,希望能得到您所需的答案。 – McCee
非常感謝! – razp26