title: How to use [JSInvokable] on event callback
body: <p>I followed first example in this link.
  <a href="https://docs.microsoft.com/en-us/aspnet/core/blazor/javascript-interoperability/call-dotnet-from-javascript?view=aspnetcore-6.0" rel="nofollow noreferrer">https://docs.microsoft.com/en-us/aspnet/core/blazor/javascript-interoperability/call-dotnet-from-javascript?view=aspnetcore-6.0</a></p>
  <p>Min and max values are passed onclick from NavBar.razor -&gt; index.js file, when &quot;CalculateMinMax &quot; button is clicked. My aim is to get min and max values to be printed in console.log() of index.js.</p>
  <ol>
  <li>How do I use[JSInvokable] for '_modal'(button click of CalculateMinMax)? Since it isn't a regular function but a event call back.</li>
  </ol>
  <p>Interop works, when I try calling [JSInvokable] on 'ReturnArrayAsync'.  I am not sure how to use [JSInvokable] for '_modal'. Thank you.</p>
  <p>NavBar.razor:</p>
  <pre><code>&lt;li class=&quot;dropdown-item&quot;&gt;
      &lt;button id=&quot;btn&quot; @onclick=&quot;() =&gt; _modal.Open()&quot;&gt;CalculateMinMax&lt;/button&gt;
  &lt;/li&gt;
  
          &lt;Modal @ref=&quot;_modal&quot; OnDoneCallback1=&quot;OnModalMin&quot; OnDoneCallback2=&quot;OnModalMax&quot; /&gt;
  
          @code {
  
              private Modal _modal { get; set; }
              public static string _min;
              public static string _max;
  
              private void OnModalMin(string min)
              {
                  _min = min;
              }
  
              private void OnModalMax(string max)
              {
                  _max = max;
                  ReturnArrayAsync();
              }
  
              [JSInvokable]  // 'ReturnArrayAsync' works when called, but I need to call '_modal'
              public static Task ReturnArrayAsync()
              {
                  var min = @_min;
                  var max = @_max;
                  return Task.FromResult(new string[] { min, max });
                  Console.WriteLine(&quot;return min&quot;, min);
  
              }
  
          }
  </code></pre>
  <p>Index.js:</p>
  <pre><code>$(&quot;#btn&quot;).click(function () {
               DotNet.invokeMethodAsync('AssemblyName', '_modal') // works for ''ReturnArrayAsync' but not sure how to incorporate for _modal.
               .then(data =&gt; {
               console.log(data);  // print max min value here                             
               });                         
   });
  </code></pre>