I developed a editor template wich take boolean types and creates a dropdownlist, to changed the true and false default values, into Si and No. Now when I deployed the application i didn’t realized that the boolean and Nullable<boolean> are taken like the same and affected for the name of my editor template (boolean.cshtml). Now I don’t want this, I want to modify the behavior of the editorfor, only when the datatype of the model was Nullable<boolean> not when it’s boolean. How can I handle this???
@model Nullable<bool>
@{
var listItems = new[]
{
new SelectListItem { Value = "true", Text = "Si" },
new SelectListItem { Value = "false", Text = "No" }
};
}
@Html.DropDownListFor( model => model.Value, listItems)
You can’t prevent them using the same editor template. But you can handle it within the editor template. You have:
If you read this article, you can actually see what the default template does with this to switch between two different renderings. Just steal from it:
http://bradwilson.typepad.com/blog/2009/10/aspnet-mvc-2-templates-part-3-default-templates.html