So, I have a .cshtml page with a select box, based on the chosen option I want to conditionally render one div or another. Is there a way to do this only utilizing code within the .cshtml and not having to refer back to the controller or model?
<div class="text-center">
<select id="Select">
<option value="1">Option 1</option>
<option value="2">Option 2</option>
<option value="3">Option 3</option>
<option value="4">Option 4</option>
<option value="5">Option 5</option>
</select>
@if(someOptionFromTheSelect == 1)
{
<div>Render this Div</div>
}
else
{
<div>Render this one</div>
}
</div>
Is there anyway to use the selected option in the conditional statement? I have tried JQuery but I cannot seem to find a way to make that accessible to the C# conditional statement.