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

Conditionally hide text fields in Blazor

$
0
0

I have a dropdown list with options '1' and '2' and text fields with the same names. My goal is that when I select option '1' from the list, only the text field named '1' should appear. When I select '2', the text field 2 should appear.

Here is my code:

<InputSelect id="value" DisplayName="value" @bind-Value="@selectValue"             style="width: 85px; margin-left: 10px; margin-top: 15px" onchange="@Show"><option value="select">Select</option><option value="one">1</option><option value="two">2</option></InputSelect><div hidden="isShow" class="col-2" style="margin-left: 9px;"><label for="One">1</label><InputNumber id="one" @bind-Value="commands.One" style="width: 80px;" /></div><div hidden="isShow" class="col-3"><label for="Two">2</label><InputText id="two" @bind-Value="commands.Two" style="width: 150px;" /></div>@code {    private bool IsShow { get; set; } = false;    private void Show()    {        IsShow = !IsShow;        Console.WriteLine(selectValue);    }}private string selectValue { get; set; } = "select";

I have tried to write a function that would make them disappear, but I've not succeeded. What am I doing wrong here?


Viewing all articles
Browse latest Browse all 4839

Trending Articles



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