Closed MichalCadecky closed 3 years ago
From the error, it cannot determine the validation handler. First, add a Model parameter to Validations. Then use two-way binding: @bind-SelectedValue="@selectedOption"
.
Also, now I noticed that I Validator parameter is missing from SelectList, I will need to add it.
Thank you! Adding Model to Validations and using @bind-SelectedValue=
works but I would like to use SelectedValueChanged=
handler and that is not possible with @bind-SelectedValue=
. I have to change it back to SelectedValue=
and doing so will end with the same errors.
It is possible but you need to use some "secret" Blazor feature(SelectedValueExpression).
So, try this:
SelectedValue="@selectedOption" SelectedValueChanged="@OnSomething" SelectedValueExpression="@(()=>model.FieldName)"
Perfect! Finally it is working. Thanks for pointing this one out. I am closing the issue :) And thanks for the great work you are doing!
Describe the bug I was trying to use SelectList with Validation and it seems there is a bug when validation is being performed. It always ends up with exception which can be seen in the browser console.
To Reproduce Steps to reproduce the behavior:
Expected behavior SelectList should work with Validation without errors.
Additional context Used razor page:
Error thrown after page has been loaded:
Error thrown after selection has been made:
This is very simplified version. Originally I found this issue when I was developing Blazor pages based on ABP.IO framework (AbpCrudPage with DTOs and referencing Model in Validations).
Similiar issue: #2335