title: Calling an instance method in a .razor page from JavaScript
body: <p>My main goal is to call a C# method whenever the user scrolls to the bottom of my page.
  I searched for a solution using blazor alone, but couldn't find one.</p>
  
  <p>Therefore, I'm using jQuery to register the scroll event and then I'm using JSInvokable to call the C# Method.</p>
  
  <p>jQuery code:</p>
  
  <pre><code>&lt;script&gt;
      //Used to register scroll event.
      $(window).scroll(function () {
          if ($(window).scrollTop() + $(window).height() == $(document).height()) {
              DotNet.invokeMethodAsync('Blazor-Example', 'OnScroll');
          }
      });
  &lt;/script&gt;
  </code></pre>
  
  <p>.Net code (in the .razor page):</p>
  
  <pre><code>@code {
    //This is called from jquery
    [JSInvokable("OnScroll")]
    public static void OnScroll()
    {
      //TODO: How to get hold of the razor component instance?
    }
  }
  </code></pre>
  
  <p>This works fine, but I want to call an instance method in my .razor page, not a static one.</p>
  
  <p>In other words: How can I get the instance of the razor page from JavaScript?</p>
  
  <p>I tried using a static instance of the type <code>__generated__[Name_of_the_razor_page]</code> that is set during OnInitialized(), but then my code just wouldn't compile with no errors shown.</p>
  
  <p>If it is not possible to get the instance of a razor component, is there another way to register my scroll event?</p>