Breyta

Deila með


WebPartManager.CreateErrorWebPart Method

Definition

Creates a special control that is inserted into a page and displayed for end users, when an attempt to load or create a dynamic WebPart control fails for some reason.

protected:
 virtual System::Web::UI::WebControls::WebParts::ErrorWebPart ^ CreateErrorWebPart(System::String ^ originalID, System::String ^ originalTypeName, System::String ^ originalPath, System::String ^ genericWebPartID, System::String ^ errorMessage);
protected virtual System.Web.UI.WebControls.WebParts.ErrorWebPart CreateErrorWebPart (string originalID, string originalTypeName, string originalPath, string genericWebPartID, string errorMessage);
abstract member CreateErrorWebPart : string * string * string * string * string -> System.Web.UI.WebControls.WebParts.ErrorWebPart
override this.CreateErrorWebPart : string * string * string * string * string -> System.Web.UI.WebControls.WebParts.ErrorWebPart
Protected Overridable Function CreateErrorWebPart (originalID As String, originalTypeName As String, originalPath As String, genericWebPartID As String, errorMessage As String) As ErrorWebPart

Parameters

originalID
String

A string that is the ID of the failing control. If a GenericWebPart is involved in the failure, the ID is the ID of its child server control.

originalTypeName
String

A string that is the name of the Type of the failed control. If a GenericWebPart is involved in the failure, the type name is the type of its child server control.

originalPath
String

A string that contains the path to a user control, if a GenericWebPart that contains a child user control is involved in the failure.

genericWebPartID
String

A string that returns the ID of a GenericWebPart, if that type of control was involved in the failure to load or create a control.

errorMessage
String

A string that contains the error message to display on the page.

Returns

An ErrorWebPart that is inserted into a page in place of a control that failed to be loaded or created.

Remarks

The CreateErrorWebPart method is called when the Web Parts control set attempts to load or create an instance of a dynamic WebPart or server control, and it fails for some reason. The method creates an ErrorWebPart object, assigns an error message to it, and returns it. The ErrorWebPart control is inserted in place of the control that failed, and its error message is displayed on the page.

You cannot call the CreateErrorWebPart method directly from your code. However, you can inherit from the WebPartManager class and extend the method. For details, see the Notes for Inheritors section.

End users can work with an ErrorWebPart control in a page much like they would a normal WebPart control. To remove the error message, they can close the control by clicking the close verb, at which point the control will be added to a PageCatalogPart object, like any other closed control. If an end user deletes an ErrorWebPart control, the server control that failed to load will also be deleted from the page.

Notes to Inheritors

If you want to customize the information that is returned in the ErrorWebPart control, you can override the CreateErrorWebPart(String, String, String, String, String) method, call the base method, assign different values to the parameters passed to the base method, and then return the resulting ErrorWebPart control. For example, if you do not want end users to see the originalPath value (which would show the virtual directory path of a user control), when you call the base method you could pass an empty string ("") for that parameter.

You can also customize the behavior of the ErrorWebPart control itself, by inheriting from it. For example, you might want to override its Title or AllowMinimize property.

Applies to

See also