Preview 7 Blazor ServerSide @Bind VS (value + @onchange) Type Conversion
See original GitHub issueHello! I open another issue here, since @guardrex recommended so here https://github.com/aspnet/AspNetCore.Docs/issues/13539#issuecomment-516067902
It’s related to https://github.com/aspnet/AspNetCore/issues/12690
The issue is that if I use @bind
inside a custom input component, while it binds the property with the <input>
value, it doesn’t raise any callback for parent components using it be notified.
So @mkArtakMSFT recommended using the (value + @onchange) route, which is fine… but then I lose the automatic type conversion that @bind
provides…
For example, if I use @bind
, the <input>
value (if I use decimal type), gets formatted with my current computer’s number formatting settings… If I change those settings, the formatting works accordingly.
With the (value + @onchange) way, I have to provide the type conversion system myself, is this the way it should work?
Regards!!
Issue Analytics
- State:
- Created 4 years ago
- Comments:5 (4 by maintainers)
If you’re trying to duplicate what
InputNumbers
and others do, then it’s probably best to just use those as examples.Preview7: https://github.com/aspnet/AspNetCore/blob/v3.0.0-preview7.19365.7/src/Components/Components/src/Forms/InputComponents/InputNumber.cs
Preview8: https://github.com/aspnet/AspNetCore/blob/release/3.0-preview8/src/Components/Web/src/Forms/InputNumber.cs
@chrdlx There are a couple of doc issues for Pre8 that indicate new functionality in these areas for Pre8. I suppose none of it will work until Pre8, but you could try adding
type="number" step="any"
to your<input>
to see if it has any effect.