B / w silverlight and javascript interaction for browser-free applications!

I did not find a single publication or textbook related to the topic mentioned above.

Basically, I have a page being viewed in a webbrowser control.

The page is a form. if the form is submitted successfully, I get a page to go to the success page (using HttpContext.Current.Server.Transfer), and if I go to this page, I would like some kind of interaction with javascript, Silverlight to let Silverlight know that the form is submitted successfully.

thank

Jamal.

PS

One way, I thought that, I would check the source of the web browser control from the SL application. but the original webbrowser property is not updated if the page is viewed on any other page using some kind of hyperlink or so.

+3
source share
1 answer

put the following javascript on this page, it will not affect your Silverlight WebBrowser control, that the form will be submitted successfully, I would suggest using Response.Redirect rathar than Server.Transfer.

    <script type="text/javascript" language="javascript" >
        window.external.notify('Your text to pass to Silverlight');
    </script>

Log the ScriptNotify event of the WebBrowser control in Silverlight.

Xaml:

    <WebBrowser x:Name="myWebBrowser" ScriptNotify="myWebBrowser_ScriptNotify" ></WebBrowser>

Code for:

    private void myWebBrowser_ScriptNotify(object sender, NotifyEventArgs e)
    {
        string response = e.Value; // e.Value will be "Your text to pass to Silverlight"
    }
+2
source

Source: https://habr.com/ru/post/1772204/


All Articles