I have the following code
<div> @Html.LabelFor(m=>m.WrongLogin) </div>
I want to display the label dynamically based on a condition from the server side code in the controller. If the controller returns false
value then I need to make the label visible
.
Just use an if
statement:
@if (Model.LoginFailed) // Or whatever...
{
@Html.LabelFor(m => m.WrongLogin);
}
See more on this question at Stackoverflow