November Happy Hour will be moved to Thursday December 5th.

Inform user when MovingPage has been cancelled

Vote:
 
Hello, We are using the MovingPage-event to prevent pages from being removed in some cases. When we set CancelAction to true however, we want to inform the user that the action has been cancelled and the reason for this. Is it possible to return an error message to the user from global.asax? Perhaps a javascript alert window or something like that? Thanks, Christoffer
#13049
May 22, 2007 17:18
Vote:
 
I managed to do this by running the following code just before setting CancelAction = true string JavaScriptString = ""; HttpContext.Current.Response.Write(String.Format(JavaScriptString, "error message")); /Christoffer
#15316
May 23, 2007 11:12
Vote:
 
Hi Christoffer! Im afraid that there is no supported way to "send" an error message back to the user, PageEventArgs doesnt contain such a "channel". A somewhat "hacky" (and thus unsupported) way to accomplish this would be to use HttpContext.Current.Handler and register some javascript to be executed when page loads. Something like this: protected static void OnMovingPage(object sender, PageEventArgs e) { e.CancelAction = true; if (null != HttpContext.Current) { Page page = HttpContext.Current.Handler as Page; if (null != page) { page.ClientScript.RegisterClientScriptBlock(typeof(debug), "message", @" <SCRIPT type=text/javascript><![CDATA[ window.attachEvent('onload', function () { alert('Couldnt delete page because....'); }); ]]></SCRIPT> "); } } } Note that you have to check HttpContext.Current.Handler for validity, as the MovingPage event might be triggered from scheduled jobs or other background threads running without user intervention. Best regards, Johan Olofsson EPiServer AB
#15317
May 23, 2007 11:12
* You are NOT allowed to include any hyperlinks in the post because your account hasn't associated to your company. User profile should be updated.