The HtmlObject provides all the necessary functionality to register managed event handlers for script and DOM events, but what if the class you need to listen to doesn’t exist as a DOM element, but a scripting variable (referenced via ScriptObject) instead?
The HtmlObject provides all the necessary functionality to register managed event handlers for script
Share
As stated by AnthonyWJones, Silverlight can’t attached to JavaScript events. The right thing to do in this situation is to do the following:
Enable scripting access in Silverlight:
ScriptableType attribute, or mark
the specific methods with
ScriptableMember
HtmlPage.RegisterScriptableObject in
the constructor.
Once everything is set up in the Silverlight code, here’s what you do in JavaScript:
object and register an event handler
the Silverlight control
JavaScript event handler. For
example,
silverlight.Content.Page.UpdateText(text).
So basically, all event handling is performed in JavaScript, but the JavaScript event handlers can be used to call functions in Silverlight.