I'm using MVC 2, and the Html.EditorForModel() to allow me to display an editor for the model.
I am using a model which looks something like this:
public class LoanACar
{
[DisplayNameFromResource("VehicleDetails")]
public string VehicleDetails { get; set; }
[DisplayNameFromResource("VehicleId")]
[Required]
public lo...
I have an bool property in a class. And using <%= Html.EditorForModel() %> its generating this code:
<div class="editor-field">
<input class="check-box" id="Ativo" name="Ativo" type="checkbox" value="true">
<input name="Ativo" type="hidden" value="false">
</div>
My question is: why it's creating an input hidden ?
...
When calling Html.EditorFor(m => m), where m is a public class with public properties, a hidden input and a label are displayed for properties with the [HiddenInput] attribute.
How can I hide the label without making it private or creating an editor template?
Example
public class User
{
[HiddenInput]
public Guid ID { get; s...
I have a viewmodel that has an int StateID field and a string StateName field like so:
public class DepartmentViewModel : BaseViewModel, IModelWithId
{
// only show in edit mode
public int StateId { get; set; }
// only show in display mode
public string StateName { get; set; }
}
I have a read only view that uses Displ...
Hi All
I have written an Enum extension method that allows me to create a view model and allows me to easily bind a generic Enum to a SelctList like:
this.ProductStatusList = new ProductStatusTypes().BindToSelectList<ProductStatusTypes>
(product.Status.ToString());
In my View I can then have:
<% using (Html.BeginForm()) {%> ...