OnError

Microsoft Silverlight will reach end of support after October 2021. Learn more.

Establishes a handler for the event that occurs when the Silverlight plug-in generates a run-time or parse-time error.

<object ...>
  <param name="onerror" value="scriptHandlerName" />
...
</object>

Arguments

sender

object

The Silverlight plug-in that invoked the event.

errorEventArgs

object

The error and its source location. For more information, see ErrorEventArgs.

Managed Equivalent

None. This event is an event on the Silverlight plug-in as it participates in the hosting browser's DOM, and is therefore out of the scope of the managed API for Silverlight.

Remarks

The event handled by OnError lets you specify a user-defined JavaScript error-handling function that is invoked when an error is generated in the Silverlight run-time components. The default value is null. If you are using the JavaScript helper file, Silverlight.js, and you do not set OnError to an error-handling function, the default error-handling function, default_error_handler, is used. This handler is defined in Silverlight.js.

The syntax shown is the objectparam syntax in HTML, which is what is required to set the value. You can also get the value with the following script: value = silverlightObject.onError; . However, this only references the name of the handler and is seldom useful.

Applies To

Silverlight Plug-in