Silverlight and javascript
Posted in Silverlight, tagged Javascript, Silverlight on March 25, 2008 | No Comments »
Communication between silverlight and javascript seems to be simple
To call a Javascript function from codebehind
HtmlPage.Window.CreateInstance(”FunctionName”
;
or
//if the function has parameters
HtmlPage.Window.CreateInstance(”FunctionName”, “param1″, “param2″
;
to call a method in codebehind from javascript
we have to decorate the method with “ScriptableMember”
[ScriptableMember()]
public string GetString()
{
return “this is a test”;
}
and in App.xaml.cs, we have to register our page
private void Application_Startup(object sender, [...]