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 9018535
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T04:33:06+00:00 2026-06-16T04:33:06+00:00

I am using editor templates in my code and what I noticed is that

  • 0

I am using editor templates in my code and what I noticed is that lot of the controls get the name property set based on index.

@Html.EditorFor(x => x.Emails)

Where Answers is collection of EmailViewModel object

What gets rendered is this for each of item:

<input data-val="true" data-val-number="The field must be a number." 
      data-val-required="The Email field is required." 
      id="Emails_0__EmailId" name="Emails[0].EmailId" value="1">

I tried to set the name property like this:

@Html.TextBoxFor(x => x.EmailId, new { @name = "EmailAdress" })

But this has no effect!

What do I need to do so it takes name value in effect. The main reason for doing this is for validation purposes. In my validation rules I have the following:

$("#someForm").validate({
        rules: {
            EmailAddress: {
                required: true,
                email: true
            }
        }
    });
  • 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-16T04:33:08+00:00Added an answer on June 16, 2026 at 4:33 am

    Try

    @Html.EditorFor(x => x.Emails, "string", "EmailAddress") //or EmailAdress
    

    MSDN reference has the following, you are interested in the htmlFieldName

    public static MvcHtmlString EditorFor<TModel, TValue>(
        this HtmlHelper<TModel> html,
        Expression<Func<TModel, TValue>> expression,
        string templateName,
        string htmlFieldName
    )
    

    A string that is used to disambiguate the names of HTML input elements that are rendered for properties that have the same name.

    To edit the prefix you can set this in your controller

    ViewData.TemplateInfo.HtmlFieldPrefix
    

    or in your view

    @Html.ViewContext.ViewData.TemplateInfo.HtmlFieldPrefix = "Foo"
    

    Of course you could write your own helper that does this wherever you use it.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Is there a way to get HTML contents from TinyMCE editor using jQuery so
I have Drupal 6 website which is using FCK Editor as HTML editor. It
I am using shared editor templates to render nested collections in my view with
I'm looking into creating a web-based code editor pane on my CMS. I would
I am using telerik controls in my project, any body tell how to get
I'm using editor from Kendo UI, so I have big problem. I don't know
I´m using NSIS editor to make a setup for my application, but I don´t
I'm using markdown editor in my app. $(document).ready(function () { var converter = Markdown.getSanitizingConverter();
I'm using Aloha editor for editing content on a website powered by PHP and
I am using TinyMCE Editor Extender and trying to show the text on clicking

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.