title: Handle js button from C# UWP
body: <p>I am new in windows and I want to handle a button that is into a <code>WebView</code>, when press button there is a js function to execute, and I need returned params in my C# class. In Android that is very easy, something like:</p>
  
  <p>in <code>WebView</code> is loaded this code:</p>
  
  <pre><code>function sayHello(myParam) {
      BindJsInAndroid.sayHello(myParam);
  }
  
  &lt;input type="button" value="My Button" onClick="sayHello('Hello world')" /&gt;&lt;br/&gt;
  </code></pre>
  
  <p>and in android code:</p>
  
  <pre><code> WebView webView = (WebView) findViewById(R.id.web_view);
   MyJavaScriptInterface myJavaScriptInterface = new MyJavaScriptInterface(mActivityContext);
   webView.addJavascriptInterface(myJavaScriptInterface, "BindJsInAndroid");
  
  
  //into MyJavaScriptInterface class
   @JavascriptInterface
          public void sayHello(String myParam) {
              //here I get myParam
          }
  </code></pre>
  
  <p>Is there a way to do that in UWP?</p>
  
  <p><strong>EDIT</strong></p>
  
  <p>I tried as is mentioned on msdn <a href="https://msdn.microsoft.com/library/windows/apps/windows.ui.xaml.controls.webview.addweballowedobject.aspx" rel="nofollow">docs</a> but can't get it work:</p>
  
  <p>so my html src is:</p>
  
  <pre><code>&lt;html&gt;
  &lt;head&gt;
  
  &lt;script type="text/javascript"&gt;
   function js_function() {
          bind_object.js_fun();
      }
  &lt;/script&gt;
  &lt;/head&gt;
  &lt;body&gt;
  
  &lt;div&gt;
  &lt;input type="button" value="Button" onClick="js_function()" /&gt;
  &lt;/div&gt;
  &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>
  
  <p>and I have in my C# code:</p>
  
  <pre><code>public MainPage() {
          InitializeComponent();
  
       //load html src
       webView.NavigateToString(mas);
  
       //bind js with C#
       webView.AddWebAllowedObject("bind_object", new MyNativeClass());
          }
  
    [Windows.Foundation.Metadata.AllowForWeb]
      public sealed class MyNativeClass {
          public void js_fun() {
              Debug.WriteLine("get js function call");
                          }
          }
  </code></pre>
  
  <p>When I press button in webview I don't ge called <code>js_fun()</code> from C#...</p>