view-templates

UIHint not using EditorTemplate

允我心安 提交于 2019-12-24 03:27:06
问题 I have a model like this: public class MyModel { [ScaffoldColumn(false)] public int CharityId { get; set; } [UIHint("Charities")] public SelectList Charities { get; set; } } Then I have an EditorTemplate called Charities.cshtml: @model MyModel @Html.DropDownListFor(model => model.CharityId, Model.Charities) Then in my page: @model MyModel @Html.EditorForModel() However, no matter what, it doesn't render the Charities template. I've been wracking my brain on this, and it should work.. but it's

Correct, idiomatic way to use custom editor templates with IEnumerable models in ASP.NET MVC

泄露秘密 提交于 2019-11-26 16:03:49
This question is a follow-up for Why is my DisplayFor not looping through my IEnumerable<DateTime>? A quick refresh. When: the model has a property of type IEnumerable<T> you pass this property to Html.EditorFor() using the overload that only accepts the lambda expression you have an editor template for the type T under Views/Shared/EditorTemplates then the MVC engine will automatically invoke the editor template for each item in the enumerable sequence, producing a list of the results. E.g., when there is a model class Order with property Lines : public class Order { public IEnumerable

Correct, idiomatic way to use custom editor templates with IEnumerable models in ASP.NET MVC

不羁的心 提交于 2019-11-26 05:58:35
问题 This question is a follow-up for Why is my DisplayFor not looping through my IEnumerable<DateTime>? A quick refresh. When: the model has a property of type IEnumerable<T> you pass this property to Html.EditorFor() using the overload that only accepts the lambda expression you have an editor template for the type T under Views/Shared/EditorTemplates then the MVC engine will automatically invoke the editor template for each item in the enumerable sequence, producing a list of the results. E.g.,