editorfor

EditorFor collection of items in my model

你离开我真会死。 提交于 2019-11-28 20:14:36
问题 My ViewModel has a property that is a collection of another of my model entities, in this case CategoryTags (and each tag has a Tag and an ID). 1) Am I correct in understanding that Html.EditorFor() doesn't have an UI it can create for an ICollection? 2) Assuming #1, I've decided to make an EditorTemplate that is a textbox where my user can key in comma-separated tag names and jquery will autocomplete. Will I have to pass back the list of tag names (or their respective IDs) and then parse

Rendering the field name in an EditorTemplate (rendered through EditorFor())

不打扰是莪最后的温柔 提交于 2019-11-28 18:19:33
I'm currently building the Admin back-end for a website in ASP.NET MVC. In an ASP.NET MVC application, I've started using the 'EditorFor' helper method like so: <div id="content-edit" class="data-form"> <p> <%= Html.LabelFor(c => c.Title) %> <%= Html.TextBoxFor(c => c.Title)%> </p> <p> <%= Html.LabelFor(c => c.Biography) %> <%= Html.EditorFor(c => c. Biography)%> </p> </div> In the model, the 'Biography' field has been decorated with: [UIHelper("Html")]. I have an 'Html' partial view (under Views/Shared/EditorTemplates): <%@ Control Language="C#" Inherits="System.Web.Mvc.ViewUserControl<System

unable to apply Bootstrap classes to my EditorFor

不问归期 提交于 2019-11-28 14:03:06
I am working on an asp.net mvc-5 web application , and i wrote the following :- @Html.EditorFor(model => model.Name, new { htmlAttributes = new { @class = "form-control" } }) & @Html.EditorFor(model => model.Name, new { @class = "form-control" }) but this will not have any effect on the generated html, but if i changed the EditorFor to be T extboxFor i will get the effect for the form-control class ? can anyone advice on this please ? i read that this is supported only inside asp.net mvc 5.1 ? so what are the available approaches i can follow to get this working other than upgrading my asp.net

How to produce non-sequential prefix collection indices with MVC HTML Editor templates?

别等时光非礼了梦想. 提交于 2019-11-28 12:52:59
The following code has been stripped down a lot, but basically what I'm looking to achieve is as follows: I'd like to able to edit Questions and their containing Answer Choices, while being able to dynamically add/remove Questions/Answer Choices from the page. Ideally, the HtmlFieldPrefix for my items would be non-sequential, but Html.EditorFor() uses a sequential index. I have a Question ViewModel that contains an IEnumerable of Answer Choices: public class QuestionViewModel { public int QuestionId { get; set; } public IEnumerable<AnswerChoiceViewModel> AnswerChoices { get; set; } } In my

MVC3 EditorFor readOnly

笑着哭i 提交于 2019-11-27 19:57:23
I want to make readOnly with EditorFor in edit page. I tried to put readonly and disabled as: <div class="editor-field"> @Html.EditorFor(model => model.userName, new { disabled = "disabled", @readonly = "readonly" }) </div> However, it does not work. How can I make to disable edit this field? Thank you. The EditorFor html helper does not have overloads that take HTML attributes. In this case, you need to use something more specific like TextBoxFor: <div class="editor-field"> @Html.TextBoxFor(model => model.userName, new { disabled = "disabled", @readonly = "readonly" }) </div> You can still

Can EditorFor() be used to create <input type=“file”>?

此生再无相见时 提交于 2019-11-27 17:15:06
问题 Given this model, is it possible to use the Html.EditorFor() to render a file upload input element to the page? I played around with the Datatype of the property FileName, and it was definitely impacting the editor form rendered. public class DR405Model { [DataType(DataType.Text)] public String TaxPayerId { get; set; } [DataType(DataType.Text)] public String ReturnYear { get; set; } public String FileName { get; set; } } Strongly Typed *.aspx page looks like this <div class="editor-field"> <%

EditorFor() for a List of Complex Type (MVC)

眉间皱痕 提交于 2019-11-27 13:18:29
I'm trying to create an EditorFor() for a List of a Complex Type. Specifically the "Options" below should get displayed in a one multitext input where each option(string) is in a new line. However, I can only display one option in a textbox and not all options.... My View Model and Class: public class ItemViewModel { public int itemId { get; set; } [UIHint("Option")] public List<Option> Options { get; set; } } public class Option { public string Text { get; set; } } My Editor Templates: EditorTemplates\Item.cshtml @model ItemViewModel @Html.EditorFor(model => model.Options) EditorTemplates

Converting HTML.EditorFor into a drop down (html.dropdownfor?)

时间秒杀一切 提交于 2019-11-27 13:16:51
Currently I am using a Html.EditorFor control in a default 'Create' View page like this. <%: Html.EditorFor(model => model.IsActive) %> I would like to convert this to a drop down with values and still be binded to the model in the view. My question is two fold. If there are only 2/3 values needed in the drop down..Is there a quick way to explicitly populate 2 or 3 values? If the list is big and needs to come from a sql query, how to do this? Thanks in advance for the help. In order to generate a dropdownlist you need 2 properties on your view model: a scalar property to bind the selected

Rendering the field name in an EditorTemplate (rendered through EditorFor())

倖福魔咒の 提交于 2019-11-27 11:15:19
问题 I'm currently building the Admin back-end for a website in ASP.NET MVC. In an ASP.NET MVC application, I've started using the 'EditorFor' helper method like so: <div id="content-edit" class="data-form"> <p> <%= Html.LabelFor(c => c.Title) %> <%= Html.TextBoxFor(c => c.Title)%> </p> <p> <%= Html.LabelFor(c => c.Biography) %> <%= Html.EditorFor(c => c. Biography)%> </p> </div> In the model, the 'Biography' field has been decorated with: [UIHelper("Html")]. I have an 'Html' partial view (under

How to produce non-sequential prefix collection indices with MVC HTML Editor templates?

耗尽温柔 提交于 2019-11-27 07:17:45
问题 The following code has been stripped down a lot, but basically what I'm looking to achieve is as follows: I'd like to able to edit Questions and their containing Answer Choices, while being able to dynamically add/remove Questions/Answer Choices from the page. Ideally, the HtmlFieldPrefix for my items would be non-sequential, but Html.EditorFor() uses a sequential index. I have a Question ViewModel that contains an IEnumerable of Answer Choices: public class QuestionViewModel { public int