editorformodel

Html.EditorForModel and format of display

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...

Why ASP.NET MVC 2 is rendering this code?

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 ? ...

Hide editor-label for public property when calling EditorFor(...)?

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...

Showing Different fields in EditorForModel vs. DisplayForModel modes in MVC2

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...

ASP.Net MVC 2,0 EditorForModel Question

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()) {%> ...