Monday, April 18, 2011

Event Handler: Enable Error Message

In SharePoint, event handler is triggered before or after a specific event, A cancel update (properties.Cancel) is an unhandled exception for SharePoint and error message is shown as below:


The following code will be triggered before adding a field and an error message will be shown as below.

public override void FieldAdding(SPListEventProperties properties)
        {
            properties.ErrorMessage = "error”;
            properties.Cancel = true;
        }

By default, the error message will be shown as below when the attributue of CallStack is true in web.config (a xml document defines configuration of the web application). The error message will show the exception detail when admin enables the CallStack attribute


If I update the attribute of CallStack to “false”, the information for debugging will be totally hidden.


References:

No comments:

Post a Comment