In my view, I have a statement like this:
<li>@Html.EditorFor(model => model.SomeEnum, "Enum", new { ShowDefaultText = false })</li>
I have a Enum (SomeEnum) and I have a editor for template for enums. In my editor for template I'm trying to check the ViewData object for the anonymous class I passed it. According to he Html.EditorFor documentation, the third parameter is additional view data that will be with the ViewDataDictionary object.
However, in my template when looking at the ViewData class, I don't see the anonymous class/property in it. Am I doing something wrong, am I looking at the wrong object in my editor for template?
Use the following ViewData syntax
@{
var boolValue = Convert.ToBoolean(ViewData["ShowDefaultText"]);
}
@if (!boolValue)
{
...............
}
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