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

  • Home
  • SEARCH
  • 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 9120347
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T05:36:26+00:00 2026-06-17T05:36:26+00:00

My Quesiton: Within my view model I created a class InterfaceDisplay that houses some

  • 0

My Quesiton: Within my view model I created a class InterfaceDisplay that houses some display properties and other meta data for setting up my interface entry form.

I’m wondering why when I set a custom id using the additionalViewData object, ex. @Html.EditorFor(item => item.Interface.DependantSystem, new { @id = "ls" }) is my control id still set to the auto generated id="Interface_DependantSystem" I’ve overwritten ids from properties straight from the ViewModel but when they are properties within an object no dice.

My View Model:

public class ApplicationViewModel
{
    //Other Properties

    public class InterfaceDisplay {
        [DisplayName("Linked System")]
        public string DependantSystem { get; set; }

        [DisplayName("Data Flow")]
        public string DataFlow { get; set; }

        [DisplayName("Method")]
        public string Type { get; set; }

        [DisplayName("Name")]
        public string Name { get; set; }

        [DisplayName("Description")]
        [DataType(DataType.MultilineText)]
        public string Description { get; set; }
    }
}

My View

@model Namespaces.ApplicationViewModel
<table class="content-table">
        <tr>
            <td style="width: 240px;">
                @Html.Hidden("appid", @Model.Id)

                @Html.LabelFor(item => item.Interface.DependantSystem)
                @Html.EditorFor(item => item.Interface.DependantSystem, new { @id = "ls" })

                @Html.LabelFor(item => item.Interface.DataFlow)
                @Html.EditorFor(item => item.Interface.DataFlow, new { @id = "df" })

                @Html.LabelFor(item => item.Interface.Type)
                @Html.EditorFor(item => item.Interface.Type, new { @id = "mt" })

                @Html.LabelFor(item => item.Interface.Name)
                @Html.EditorFor(item => item.Interface.Name, new { @id = "nm" })

                @Html.LabelFor(item => item.Interface.Description)
                @Html.EditorFor(item => item.Interface.Description, new { @id = "de" })
            </td>
        </tr>
</table>
  • 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-06-17T05:36:27+00:00Added an answer on June 17, 2026 at 5:36 am

    The second argument that you are passing to the EditorFor helper is defining an additional view data for the corresponding editor template. But if you don’t write a custom editor template, then the default template will be used. And as you can see from the blog post I’ve linked to in my previous sentence, this default template does absolutely nothing with the additional view data property argument that you are passing to it.

    So if you want this parameter to have some effect you will have to write a custom template – an editor template in your case, because you are using the EditorFor helper. Since you are applying it to a property of a string type (Description) you could add the following custom editor template ~/Views/Shared/EditorTemplates/string.cshtml with the following contents:

    @Html.TextBox(
        "", 
        ViewData.TemplateInfo.FormattedModelValue,
        ViewData
    )
    

    Notice how I have overriden the default template and passed the ViewData as third argument to the TextBox helper so that the anonymous object you created in your view as second argument to the EditorFor helper ends up as HTML attributes of the corresponding input field that this template will generate.

    Now since you have overriden the default editor template for the string type whenever you use Html.EditorFor(x => x.SomePropertyOfTypeString, new { @class = "foo", id = "bar" }), this custom template will be used instead of the default one and it will generate the following markup for you:

    <input class="foo" id="bar" name="Description" type="text" value="some value" />
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have the following view within an app called 'manager': class AddObj(CreateView): model =
I have a link within my View and when users click on that link
I'm working on creating a validation view using backbone that will handle the display
Simple question. Why use require_once to include classes that you use within a file?
Say I have an Article model, and in the article 'new' view I have
Within an admin page I originally was generating several checkboxes within a view as
I've set up a little n-tier web application using MVP (Model View Presenter) in
How can I get a WPF ComboBox that is within a DataTemplate within an
I have a model with various properties but the one of interest is a
I'm creating an application that enables a user to insert, update and delete data

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.