FAQ Database Discussion Community


Is this the correct way to do an Editor Template?

vb.net,asp.net-mvc-5,mvc-editor-templates
I would like to know know if I am doing an editor template correctly. And If I am doing it incorrectly, can you point me in the right direction to do it properly. My Editor Template for a textarea: @modeltype IEnumerable(Of be_PostTag) @code If Model Is Nothing Then @Html.TextArea("PostTags") Else...

HttpPostedFileBase Editor Template in ASP.NET MVC

c#,asp.net-mvc,mvc-editor-templates,asp.net-mvc-5.2
I am working with ASP.NET MVC 5 and have this simple ViewModel. public class ArtistVM { public string FName { get; set; } public string LName { get; set; } public HttpPostedFileBase ImgUpload { get; set; } } I know that I require a custom editor template for HttpPostedFileBase, so...

EditorTemplates Where or Groupby on Questionnaire

asp.net-mvc-5,mvc-editor-templates,editortemplates
At the moment, I have a working prototype for a questionnaire with multiple questions and each question having multiple choices for an answer. Everything displays and saves great. However, I now would like to group the question/answers into 'sections' on my Edit view. I have tried a couple different methods...

How can I test for [AllowHtml] attribute within an editor template?

asp.net-mvc,data-annotations,mvc-editor-templates
I would like to be able to test a property for the [AllowHtml] attribute from within an editor template. It doesn't seem to be lurking within ViewData.ModelMetadata. I've tried iterating through ViewData.ModelMetadata.AdditionalValues to see if it's there, but it doesn't appear to be. I've scoured Google and Brad Wilson's post...

Rendering 2-column layout in an Editor Template

asp.net-mvc,razor,twitter-bootstrap-3,mvc-editor-templates
I'd like to have a 2 column layout, but the problem is I can't place half my HTML codes inside else segment. Any Idea? This is the editor template: @{int i = 0;} @foreach (var property in ViewData.ModelMetadata.Properties) { if (property.PropertyName.StartsWith("Z") || property.IsReadOnly) { continue; } if (i++ % 2...

Radio Buttons in Editor Template

asp.net-mvc,radio-button,survey,mvc-editor-templates
I am in the process of creating a 'Progress Report' with a list of questions and multiple choice answers. The questions are populated into the Progress Report automatically via a separate unrelated process in case it is relevant. Code is as follows: Edit View: @model App.Models.ProgressReport @Html.EditorFor(model => model.ReportAnswers) ReportAnswer.cshtml...

Radio button list using editor templates for merging contacts

asp.net,asp.net-mvc,radio-button,radiobuttonlist,mvc-editor-templates
I am trying to display a form for merging two contacts in ASP.net MVC 5. The form should look like this where each row holds a radio button group consisting of 2 options: The form shows up just fine, and the radio groups work (I can select each group). However,...

Client-side unobtrusive validation for EditorTemplate when sending IEnumerable

asp.net,asp.net-mvc,unobtrusive-validation,fluentvalidation,mvc-editor-templates
There is a possibility that I just wasn't able to find the solution, or lack thereof, through my searches. Maybe I didn't word it properly, but my problem is trying to get client-side unobtrusive validation to fire on an EditorTemplate when I pass an IEnumerable<T> to it. My setup: ParentModel.cs...

What is the preferred way to standardise complex html views for data types?

asp.net-mvc,html-helper,mvc-editor-templates
I have code like this that I repeat through many MVC editing views. This example is the default way we display a checkbox, but similar repetition is found with other input types. <div class="form-group"> @Html.LabelFor(model => model.IsLive, htmlAttributes: new { @class = "control-label col-md-3" }) <div class="col-md-8 checkbox"> <div class="col-xs-1">...

Customizing Html.LabelFor

asp.net-mvc,razor,mvc-editor-templates
I'd like to add some classes to my labels, so I added Label.cshtml Under Shared/EditorTemplates folder. It seems Razor is ignoring it. I've tried DisplayTemplatesfolder too, but it didn't work neither. Can I have editor template for labels? If no, what's the best way to customize them? Label.cshtml: @model object...

Missing data when submit with DateTime and editor template in MVC5

asp.net,asp.net-mvc-5,mvc-editor-templates
I'm new in MVC. I use editor template for create 3 textbox for day, month, year for datetime type. Main View: @model mvc3date.Models.SomeDate ... <html> ... <body> @using (Html.BeginForm()) { ... <div class="form-group"> @Html.LabelFor(model => model.oneday, new { @class = "control-label col-md-2" }) <div class="col-md-10"> @Html.EditorFor(model => model.oneday) @Html.ValidationMessageFor(model =>...