Tuesday, December 17, 2013

Call JavaScript function from Silverlight Code behind

Here is a very simple code to display an Javascript alert from Silverlight code behind.
Silverlight Code behind C#:

private void Button_Click(object sender, RoutedEventArgs e)
{
      HtmlPage.Window.Invoke("showAlert", "Hello!");
}

JavaScript:

function showAlert(message) 
{
    alert(message);
}

No comments:

Post a Comment