I'm creating user control in MVC3 application. My view model looks like that:
public class MyViewModel { public object Value { get; set; } }
The Value property could be an int, string or bool so I can't use [DataType]
attribute.
When I create my view model:
var viewModel = new MyViewModel { Value = "" };
or
var viewModel = new MyViewModel { Value = 1 };
I assume that this code:
<%: Html.EditorFor(p => p.Value) %>
should render an HTML input of type textbox. Unfortunately nothing is being rendered.
Everything works fine when I use bool value or some not empty string. Here's an example:
var viewModel = new MyViewModel { Value = true };
Html.EditorFor
renders checkbox input:
I did some research, but for now I didn't found solution.