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?
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
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