I have a bool in my ViewModel called DisableNextButton and I would like to use it to disable a button in my view. I should add that this button lives inside an if statement.
Ultimately, I'm trying to add the disabled attribute when DisableNextButton is true.
Here's my unsuccessful implementation:
@if(true)
{
<button type="button" @{ if (Model.DisableNextButton) { <text>disabled="disabled"</text> } } >Next</button>
}
I should note that this gives me a functioning enabled button.
Translated from this post:
<input type="button" value="Next"
@{
if(Model.DisableNextButton)
{
@:disabled="disabled"
}
}
/>
Basically, the <text> tag is unnecessary, as this is not text, it's an HTML attribute.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With