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

Blazor InputCheckbox @onchange event not working

$
0
0

I have a Blazor form on a .RAZOR page:

<EditForm Model="@myModel" OnValidSubmit="@doThis"><InputCheckbox class="someClass" id="someId" @bind-value="booleanValue" @onchange="e=>{doSomething(e);}"></InputCheckbox></EditForm>@code {    public MyModel myModel = new MyModel();    public bool booleanValue = true;    public void doSomething(ChangeEventArgs e) {        // Stuff here ...    }    public async Task doThis(){        // Stuff here ...    }}

When I put a breakpoint at public void DoSomething it never gets hit.

However, if I change the @onchange to @onclick, the public void DoSomething method gets hit every time. The only thing is that the @onclick doesn't let me know what has changed, meaning "is it clicked -to-> unclicked or is it unclicked -to-> clicked".

So, why is the @onchange event never firing, and how can I get it to work?


Viewing all articles
Browse latest Browse all 4382

Latest Images

Trending Articles



Latest Images

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