Hi,
I'm using a modal RadWindow control as a popup which allows users to select certain elements for processing. When this processing successfully completes, the RadWindow uses the RegisterStartupScript method of the ScriptManager object to call a Javascript function which closes the RadWindow and runs another Javascript function on the parent page to refresh a RadGrid control.
In the RadWindow code behind, the button that initiates the processing is tied to a RadAjaxPanel control for the purpose of displaying a LoadingPanel. I am overriding the OnError event to capture and record the details of any error that bubbles up from the other application layers.
The code works wonderfully when the processing completes successfully, or when a user clicks on a "cancel" button to exit the RadWindow and return to the parent page. However, if there is an error, I can't figure out how to get the RadWindow to close. I'm using IE 7, and all I see is the yellow "warning" triangle that contains mention of an error message to the effect of "'length' is null or not an object" (although I'm not using the "length" property of anything, referencing arrays, etc. in my code).
In the overridden OnError event, I've tried using ScriptManager.RegisterStartupScript and ClientScript.RegisterStartupScript, and good old Response.Write() to try to get the page to run any Javascript after the error--but nothing is working. Any ideas on what I'm missing? Code is below:
RadWindow definition on the parent page:
Javascript definition in the RadWindow's markup:
Relevant methods from the RadWindow code-behind:
Ultimately I would like the Javascript function to redirect the parent page to a custom error screen. I'm pretty sure I can do this once I get the RadWindow to execute any Javascript.
Thanks!
Dan
I'm using a modal RadWindow control as a popup which allows users to select certain elements for processing. When this processing successfully completes, the RadWindow uses the RegisterStartupScript method of the ScriptManager object to call a Javascript function which closes the RadWindow and runs another Javascript function on the parent page to refresh a RadGrid control.
In the RadWindow code behind, the button that initiates the processing is tied to a RadAjaxPanel control for the purpose of displaying a LoadingPanel. I am overriding the OnError event to capture and record the details of any error that bubbles up from the other application layers.
The code works wonderfully when the processing completes successfully, or when a user clicks on a "cancel" button to exit the RadWindow and return to the parent page. However, if there is an error, I can't figure out how to get the RadWindow to close. I'm using IE 7, and all I see is the yellow "warning" triangle that contains mention of an error message to the effect of "'length' is null or not an object" (although I'm not using the "length" property of anything, referencing arrays, etc. in my code).
In the overridden OnError event, I've tried using ScriptManager.RegisterStartupScript and ClientScript.RegisterStartupScript, and good old Response.Write() to try to get the page to run any Javascript after the error--but nothing is working. Any ideas on what I'm missing? Code is below:
RadWindow definition on the parent page:
<telerik:RadWindowManager ID="RadWindowManager1" runat="server"> |
<Windows> |
<telerik:RadWindow ID="NewSamplePopup" |
Behaviors="Move,Pin" |
ReloadOnShow="true" |
Modal="true" |
runat="server" |
Height="520" |
Width="600" |
NavigateUrl="./NewSamplePopup.aspx" |
VisibleStatusbar="false" |
Title="Getting Available Sample Types...Please Wait" |
ShowContentDuringLoad="false"> |
</telerik:RadWindow> |
</telerik:RadWindowManager> |
Javascript definition in the RadWindow's markup:
<body> |
<telerik:RadCodeBlock runat="server"> |
<script type="text/javascript"> |
function GetRadWindow() { |
var oWindow = null; |
if (window.radWindow) |
oWindow = window.radWindow; //Will work in Moz in all cases, including clasic dialog |
else if (window.frameElement.radWindow) |
oWindow = window.frameElement.radWindow; //IE (and Moz as well) |
return oWindow; |
} |
function RadWindowClose() { |
GetRadWindow().Close(); |
} |
function CloseAndRebind(args) { |
GetRadWindow().Close(); |
GetRadWindow().BrowserWindow.refreshGrid(args); |
} |
</script> |
</telerik:RadCodeBlock> |
Relevant methods from the RadWindow code-behind:
protected void btnGetTests_Click(object sender, EventArgs e) |
{ |
// code that throws an error... |
} |
protected void btnCancel_Click(object sender, EventArgs e) |
{ |
// close the form - this works!!! |
ScriptManager.RegisterStartupScript(this, this.GetType(), "close", "RadWindowClose();", true); |
} |
protected override void OnError(EventArgs e) |
{ |
// At this point we have information about the error |
HttpContext ctx = HttpContext.Current; |
Exception exception = ctx.Server.GetLastError(); |
///////// |
// Logic to handle error here |
///////// |
ctx.Server.ClearError(); |
// Gets called but doesn't work! |
ScriptManager.RegisterStartupScript(this, this.GetType(), "close", "RadWindowClose();", true); |
} |
Ultimately I would like the Javascript function to redirect the parent page to a custom error screen. I'm pretty sure I can do this once I get the RadWindow to execute any Javascript.
Thanks!
Dan