Quantcast
Channel: Active questions tagged blazor - Stack Overflow
Viewing all articles
Browse latest Browse all 4839

not binding with @bind in Blazor WASM in .NET 9

$
0
0

I'm try to bind radio buttons using @bind in Blazor wasm. But not able to make successful attempt and also not able to find any docs for this.

I searched in this doc link - https://learn.microsoft.com/en-us/aspnet/core/blazor/components/data-binding?view=aspnetcore-9.0

Code:

<div class="control flex flex-col"><label class="radio"><input type="radio" name="stock" @bind="Filter.InStock" checked="@(Filter.InStock.HasValue && Filter.InStock.Value)" @bind:after="LoadData" />        In Stock</label><label class="radio"><input type="radio" name="stock" @bind="Filter.OutOfStock" checked="@(Filter.OutOfStock.HasValue && Filter.OutOfStock.Value)" @bind:after="LoadData" />        Out of Stock</label></div>@code {  public class StockFilter   {      public bool? InStock { get; set; }      public bool? OutOfStock { get; set; }  }  public StockFilter Filter = new();  public void LoadData()  {      Console.WriteLine("In" + Filter.InStock);      Console.WriteLine("Out" + Filter.OutOfStock);      // make API call  }}

Console log:

enter image description here

Please can you assist me or point to correct docs link?


Viewing all articles
Browse latest Browse all 4839

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>