Calling arbitrary JavaScript from Silverlight

The question of calling JavaScript functions from Silverlight seems to come up quite often and there are solutions to the problem.  But one answer I have not seen yet is to use the HtmlPage.Window.Eval method.  This method is simply a pass-through to the Eval method in JavaScript on the browser end.  It might not be an appropriate solution in all cases, but it's always nice to have options!

   1:  // C# Code
   2:  HtmlPage.Window.Eval(string.Format("doSomething('{0}');", "hello there!"));


   1:  // JavaScript Code
   2:  function doSomething(message) {
   3:    alert(message);
   4:  }
Comments have been closed on this topic.