Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<pre><code>@model EditProductViewModel @using (Html.BeginForm("Edit", "ProductData", FormMethod.Post)) { @Html.EditorFor(o=&gt; o.ProductData ) @Html.EditorFor(o=&gt; o.FridgeContent ) } </code></pre> <p>or create an edit template for you ViewModel containing these two lines</p> <pre><code> @Html.EditorFor(o=&gt; o.ProductData ) @Html.EditorFor(o=&gt; o.FridgeContent ) </code></pre> <p><strong>UPADTE:</strong></p> <p>Oh got it finally because the rendering engine will not go more that one step in object hierarchy, you can find it in asp.net mvc code also.</p> <p>Check the MVC 3.0 Source Code <a href="http://aspnet.codeplex.com/releases/view/58781" rel="nofollow">Here</a>:</p> <p>There is a file named <code>DefaultEditorTemplates.cs</code> which contains this method:</p> <pre><code>internal static string ObjectTemplate(HtmlHelper html, TemplateHelpers.TemplateHelperDelegate templateHelper) { ViewDataDictionary viewData = html.ViewContext.ViewData; TemplateInfo templateInfo = viewData.TemplateInfo; ModelMetadata modelMetadata = viewData.ModelMetadata; StringBuilder builder = new StringBuilder(); if (templateInfo.TemplateDepth &gt; 1) { // DDB #224751 return modelMetadata.Model == null ? modelMetadata.NullDisplayText : modelMetadata.SimpleDisplayText; } foreach (ModelMetadata propertyMetadata in modelMetadata.Properties.Where(pm =&gt; ShouldShow(pm, templateInfo))) { if (!propertyMetadata.HideSurroundingHtml) { string label = LabelExtensions.LabelHelper(html, propertyMetadata, propertyMetadata.PropertyName).ToHtmlString(); if (!String.IsNullOrEmpty(label)) { builder.AppendFormat(CultureInfo.InvariantCulture, "&lt;div class=\"editor-label\"&gt;{0}&lt;/div&gt;\r\n", label); } builder.Append("&lt;div class=\"editor-field\"&gt;"); } builder.Append(templateHelper(html, propertyMetadata, propertyMetadata.PropertyName, null /* templateName */, DataBoundControlMode.Edit, null /* additionalViewData */)); if (!propertyMetadata.HideSurroundingHtml) { builder.Append(" "); builder.Append(html.ValidationMessage(propertyMetadata.PropertyName)); builder.Append("&lt;/div&gt;\r\n"); } } return builder.ToString(); } </code></pre> <p>which clearly states that if the <code>TemplateDepth &gt; 1</code> just render a simple text.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload