title: Call a function on button click in Blazor/Razor - ASP.NET Core 3
body: <p>I just started learning ASP.NET Core and I was following the YouTube tutorial from Microsoft (<a href="https://www.youtube.com/watch?v=wA-3FA2kbpA&amp;list=PLdo4fOcmZ0oW8nviYduHq7bmKode-p8Wy&amp;index=11" rel="nofollow noreferrer">https://www.youtube.com/watch?v=wA-3FA2kbpA&amp;list=PLdo4fOcmZ0oW8nviYduHq7bmKode-p8Wy&amp;index=11</a>) and when I tried to call the function on button click, it does not work.</p>
  
  <p>The code is as follows:</p>
  
  <p><strong>Button in HTML</strong> </p>
  
  <pre><code>&lt;button @onclick="(e =&gt; SelectProduct(product.Id))" data-toggle="modal" data-target="#productModal" class="btn btn-primary"&gt;More Info&lt;/button&gt;
  </code></pre>
  
  <p><strong>@Code Element - Function</strong></p>
  
  <pre><code>void SelectProduct(string productId)
  {
      selectedProductId = productId;
      selectedProduct = ProductService.GetProducts().First(x =&gt; x.Id == productId);
  }
  </code></pre>
  
  <p>Kindly help me debug this. The function does not get called when the button is clicked. <br/> Thanks in advance!</p>