ASPxScheduler.CustomErrorText Event
Enables you to provide custom error descriptions.
Namespace: DevExpress.Web.ASPxScheduler
Assembly: DevExpress.Web.ASPxScheduler.v19.1.dll
Declaration
Event Data
The CustomErrorText event's data class is ASPxSchedulerCustomErrorTextEventArgs. The following properties provide information specific to this event:
Property | Description |
---|---|
ErrorText | Gets or sets the explanatory text for the error. |
Exception | Gets the exception thrown. |
Remarks
The CustomErrorText event occurs when an exception is raised within the ASPxScheduler, and allows you to change the default error text. You can localize error messages via this event.
Use the ASPxSchedulerCustomErrorTextEventArgs.ErrorText property of the event’s arguments object to specify the error text for the exception returned by the ASPxSchedulerCustomErrorTextEventArgs.Exception property.
The following code snippets illustrate a way of handling the ASPxScheduler.CustomErrorText
event to display custom text when an unhandled exception occurs.
Note
A complete sample project is available at https://github.com/DevExpress-Examples/how-to-use-the-customerrortext-event-e1827
public class ErrorTextHelper {
static string NewLinesToBr(string text) {
text = text.Replace("\r", string.Empty);
return text.Replace("\n", "<br/>");
}
public static string PrepareMessage(string subjectText, string detailInfoText, bool showDetailedErrorInfo) {
string subject = String.Format("{0}\n", subjectText);
string detailInfo = String.Format("Detailed information is included below.\n\n- {0}", detailInfoText);
if(!showDetailedErrorInfo)
detailInfo = String.Empty;
subject = NewLinesToBr(HttpUtility.HtmlEncode(subject));
detailInfo = NewLinesToBr(HttpUtility.HtmlEncode(detailInfo));
return String.Format("{0},{1}|{2}{3}", subject.Length, detailInfo.Length, subject, detailInfo);
}
}