Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7197001
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T20:53:11+00:00 2026-05-28T20:53:11+00:00

Following Brad Wilson’s excellent series on using and customizing editor templates , I tried

  • 0

Following Brad Wilson’s excellent series on using and customizing editor templates, I tried adding an Object.cshtml to the Shared\EditorTemplates folder. The template renders, but the [HiddenInput(DisplayValue = false)] on a model property doesn’t render a hidden <input type="hidden" ... /> as expected. Using [HiddenInput(DisplayValue = true)] renders both the hidden and visible elements as expected.

I have verified that the default template for Object works fine and renders the hidden inputs. It’s only a problem when building a custom template based on Brad’s series above.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-28T20:53:13+00:00Added an answer on May 28, 2026 at 8:53 pm

    Looks like something has changed. Inspecting the MVC 3 source, I found that prop.HideSurroundingHtml is used to determine when to print the surrounding HTML, not to print only the hidden element. The following template allows several levels of rendering an editor for an object graph:

    @if (ViewData.TemplateInfo.TemplateDepth > 2)
    {
        @(ViewData.ModelMetadata.Model != null ?
            ViewData.ModelMetadata.SimpleDisplayText :
            ViewData.ModelMetadata.NullDisplayText)
    }
    else
    {
        foreach (var prop in ViewData.ModelMetadata.Properties.Where(pm => pm.ShowForEdit && !ViewData.TemplateInfo.Visited(pm)))
        {
            if (!prop.HideSurroundingHtml)
            {
                if (!String.IsNullOrEmpty(Html.Label(prop.PropertyName).ToHtmlString()))
                {
                    <div class="editor-label">@Html.Label(prop.PropertyName)</div>
                }
                @Html.Raw("<div class=\"editor-field\">")
            }
            @Html.Editor(prop.PropertyName)
            if (!prop.HideSurroundingHtml)
            {
                @Html.ValidationMessage(prop.PropertyName, "*")
                @Html.Raw("</div>")
            }
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

in the following post: http://bradwilson.typepad.com/blog/2009/10/aspnet-mvc-2-templates-part-4-custom-object-templates.html <%= Html.Editor(prop.PropertyName) %> Html.Editor creates a text box with
I was reading one of Brad Wilson's articles: ASP.NET MVC 2 Templates, Part 2:
Following this documentation ( https://docs.djangoproject.com/en/dev/topics/http/views/#customizing-error-views ), I am trying to create a custom error
I have the following code in a partial class and I'm using LINQ to
The Scenario I have been following Brad Abrams Silverlight With Ria Tutorials In order
I need TextBox which will reflect changes in databound string. I tried following code:
I have the following table in an application I am developing using ruby on
Following http://maksim.sorokin.dk/it/2010/06/10/izpack-with-maven/ I wrote a Maven POM which creates an IzPack installer, using the
How does one accomplish model-level validation as stated in Brad Wilson's post: Finally, if
Following a previous question I posted and received an excellent answer to - Dynamically

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.