Calling Silverlight Method from Javascript and Javascript Function from Silverlight - Online Free Computer Tutorials.

'Software Development, Games Development, Mobile Development, iOS Development, Android Development, Window Phone Development. Dot Net, Window Services,WCF Services, Web Services, MVC, MySQL, SQL Server and Oracle Tutorials, Articles and their Resources

Tuesday, December 6, 2011

Calling Silverlight Method from Javascript and Javascript Function from Silverlight

Introduction

When working with silverlight, we are working with manage code (C#,VB). sometimes we will need to callback to html page from manage code.

In this article we walkthrough how to calling manage code from javascript and calling javascript function from manage code. 

Background

To call javascript function from silverlight, HtmlPage class of System.Windows.Browser namespace is used to allow user to access and manipulate browser DOM (Document Object Model).

ScriptableMemberAtrribute class indicates that method or property is accessible for javascript caller.

To permit user to access method of silverlight from javascript you have to set [ScriptableMember] attribute to that method.

Using the code

Let's start with step by step including source to demonstrate how to communication between javascript and silverlight.

No comments:

Post a Comment