views:

359

answers:

2

Can I use javascript in a page to cause an event in a silverlight component to fire? If so, does anybody have some code samples?

+3  A: 

Yes, you can. You need to decorate a method on a class in your .NET code with the "ScriptableMember" attribue and then call HtmlPage.RegisterScriptableObject on your object to mark it for interoperability with javascript. You'd create your .NET method called something like OnMyEvent(sender As Object, e As MyEventArgs) which would then raise the object's event that you want. Your javascript would then call that.

See this link for a walkthrough: http://msdn.microsoft.com/en-us/library/cc221414(VS.95).aspx

Tom
+2  A: 

Video walk through here: http://silverlight.net/learn/learnvideo.aspx?video=65683

Tim Heuer