Is is possible to bind a value in Blazor client in particular format.
For example
<input type="text" bind="@TestDate.ToString("dd.MM.yyyy")" />
@code
{
protected DateTime TestDate {get;set;} = DateTime.Now;
}
I tried to do
<input type="text" bind="@TestDate" format-value="dd.MM.yyyy" />
but that didnt do anything, i received a value such as 11/12/2019 1:03:17 PM
Bind a property or field on other Document Object Model (DOM) events by including an @bind:event="{EVENT}" attribute with a DOM event for the {EVENT} placeholder. The following example binds the InputValue property to the <input> element's value when the element's oninput event ( input ) is triggered.
You can use the bind attribute on any element to bind the value. In blazor, we'll have a property assigned some value in the functions and use the property in the HTML template. Let's get this done. So, when we run the app, the label tag will display “red” as a text in the label.
In Blazor, there is no significant difference between using these two attributes. The @bind attribute is a shorthand of the @bind-value attribute and its delegate will trigger the ValueChanged event of the component.
We can bind a drop-down list in Blazor WebAssembly using the <select> tag and bind the values to the drop-down list using the @bind attribute in the tag.
It's bind:format
, you have sample in the doc : Data binding paraph format string
<input @bind="StartDate" @bind:format="yyyy-MM-dd" />
@code {
[Parameter]
public DateTime StartDate { get; set; } = new DateTime(2020, 1, 1);
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With