HI,
My project is using C#, Blazor Server. I have a Textbox that I need to be able to set different background / Text colors in code.
Does anyone have examples of select the Textbox and changing its properties dynamically?
Thanks
HI,
My project is using C#, Blazor Server. I have a Textbox that I need to be able to set different background / Text colors in code.
Does anyone have examples of select the Textbox and changing its properties dynamically?
Thanks
Hi @RicVA,
You can use the style attribute of RadzenTextBox like this:
<RadzenTextBox
style="@($"--rz-input-background-color: {background}; --rz-input-value-color: {color}")"
/>
@code {
string background = "red";
string color = "white";
}
Explanation:
$"--rz-input-background-color: {background}; --rz-input-value-color: {color}"
is a C# string interpolation to prevent the notorious Blazor exception that one cannot mix expressions and strings.--rz-input-background-color
and --rz-input-value-color
are CSS variables that RadzenTextBox uses for styling.