MVC 3 - Additional view data not displayed in the editor For the template

In my opinion, I have an expression like this:

<li>@Html.EditorFor(model => model.SomeEnum, "Enum", new { ShowDefaultText = false })</li> 

I have Enum (SomeEnum), and I have an editor for the template for enumerations. In my template editor, I am trying to validate a ViewData object for an anonymous class that I passed to it. According to the Html.EditorFor documentation, the third parameter is the additional view data that will be with the ViewDataDictionary.

However, in my template, when viewing the ViewData class, I do not see an anonymous class / property in it. Am I doing something wrong, am I looking at the wrong object in my editor for a template?

+8
asp.net-mvc-3
source share
1 answer

Use the following ViewData p> syntax

 @{ var boolValue = Convert.ToBoolean(ViewData["ShowDefaultText"]); } @if (!boolValue) { ............... } 
+9
source share

All Articles