Communication from silverlight to winforms via web browser

I am trying to send a JSON string through a Winforms application to a Silverlight application.

I tried several times to do this by exposing my silverlight method using

HtmlPage.RegisterScriptableObject("Page", this);
.....
[ScriptableMember]
public void CallMeInSilverlight(string message)
{
    HtmlPage.Window.Alert("The form said: " + message);
}

in javascript

function CallMe(message) {
    var control = document.getElementById('silverlightControl');
    control.Content.Page.CallMeInSilverlight(message);
}    

But for some reason I cannot do this work with javascript. It is simply not caused.

in winforms

webBrowser1.Document.InvokeScript("CallMe", new object[] { "testing 1 2 3" });

Am I doing something wrong?

+3
source share
1 answer

I noticed that when I create my project, the text page created by Silverlight overloads.

Since it was an html page where my web browser sent its javascript commands, the commands never reached the silverlight control.

After creating a separate page using javascript commands, it worked fine.

0
source

All Articles