Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR CSHARP

Conditional Blazor Styles

<input style="@StyleForNumber(MyNumber)" type="number" @bind=MyNumber @bind:event="oninput" />

@code{
	private string StyleForNumber(int n)
	{
  		if (n > 100) return "";
   		if (n < 1)  return "color:red";
   		return "background:lightgreen";
	}
}
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #Conditional #Blazor #Styles
ADD COMMENT
Topic
Name
5+8 =