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

Blazor, fill 0 value binded property as empty string in input

$
0
0

Hi I have a question,

I'm experimenting with Blazor and it has been fun but I was wondering when I bind a simple model, with one int property to a text input for example:

<input type="text" class="communication__control--input" id="broadcast-port" autocomplete="off" placeholder=" " @bind="@this.Simple.Number" />

Now property in model is just int (not nullable) so default value would be 0 for that input. So my question is can I make that 0 will show as an empty string in input and still if I write any value (for example 3 will show as 3 but 0 will show empty string) to it it will bind?

Basing @Bennyboy1973 comment, basically I could go with 2 properties one that will be binded string prop and other would be read only int that will try to convert first one, or just use 2 model combination (something like DTO and backend model) with Automapper. But is there any simpler way?


Viewing all articles
Browse latest Browse all 4839

Trending Articles



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