ScriptManager1.AsyncPostBackErrorMessage does not show error message

I always used the following two bits of code (which are used to work) to catch Ajax asyncPostBackErrors.

<asp:ScriptManager ID="ScriptManager1" runat="server" OnAsyncPostBackError="ScriptManager1_AsyncPostBackError" />

and

protected void ScriptManager1_AsyncPostBackError(object sender, AsyncPostBackErrorEventArgs e) 
{ 
ScriptManager1.AsyncPostBackErrorMessage = e.Exception.Message; 
}

But now, despite the fact that an unhandled exception fell into this function of the event handler, and AsyncPostBackErrorMessagewas installed with an exception message, I always get the same error message on the page in the warning field, regardless of whether the exception message was, saying:

Error: Sys.WebForms.PageRequestManagerParserErrorException: The message recieved from the server could not be parsed. Common causes for this error are when the response is modified by calls to the Respnse.Write() ....

Error - the same error you would get if you had an unhandled exception asyncPostBackand you didn’t include the event handler method Scriptmanger's asyncPostBackError.

No matter what I do, I get the same error. What could be the reason for this?

+3
2

, , , ScriptManager1_AsyncPostBackError. server.transfer , HTML- script.

, Server.ClearError() ScriptManager1_AsyncPostBackError. Global.Application_Error.

+2

, VS 2005 VS 2008. :

if (e.Exception is LandingPageUIExceptionInvalidMSISDN)
{
    msgresolved = "ErrorPopUpInvalidNumber";
    ScriptManager.GetCurrent(Page).AsyncPostBackErrorMessage = msgresolved;
}

. AsyncPostBackErrorMessage , , JavaScript :

var ErrorPopUpDivID = e.get_error().message;
alert(ErrorPopUpDivID);

ErrorPopUpDivID , AsyncPostBackErrorMessage. . , .NET 3.5.

, JavaScript :

var ErrorPopUpDivID = e.get_error().message;
var re = new RegExp("Sys.*: ", "g");
ErrorPopUpDivID = ErrorPopUpDivID.replace(re, "");
0

Source: https://habr.com/ru/post/1721851/


All Articles