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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T05:27:30+00:00 2026-06-08T05:27:30+00:00

With MVC, when you use something like @Html.TextBoxFor(…) the control renders using property attributes

  • 0

With MVC, when you use something like @Html.TextBoxFor(…) the control renders using property attributes from the model for things like validation.

It also uses the class’s property name as the name of the rendered HTML control. This conflicts a little with our naming conventions so I’d like to be able to control the ID a bit more.

I’ve added the ‘htmlAttributes:’ to the helper, which does what I want, but I was wondering:

  1. How does this impact MVC’s ability to instantiate the model again
    when the information is posted?
  2. Is there a way to specify the control ID using property attributes in the model class?

Thanks,
Jacques

  • 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-08T05:27:32+00:00Added an answer on June 8, 2026 at 5:27 am

    How does this impact MVC’s ability to instantiate the model again when the information is posted?

    The ID attribute has absolutely no impact on anything that is posted. The ID attribute is never used when submitting a form. The only requirement is that this attribute is unique throughout your entire DOM. It is the name attribute that is used by the model binder. You cannot change this attribute anyway using the htmlAttributes because this attribute is inferred from the lambda expression used as first argument and you shouldn’t need to change it anyway, otherwise you could break the way the default model binder rehydrates your view models.

    Is there a way to specify the control ID using property attributes in the model class?

    Yes, but it could be a little more work. You could use custom editor templates for the standard types and a custom metadata aware attribute that will pass this additional metadata information to the custom editor template. If you are interested in the implementation specifics I could provide an example but first I have to understand why you need that.

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

Sidebar

Related Questions

MVC use action attributes to map the same view for http get or post:
I use Spring MVC [version: 2.5] and Security[version: 2.0.4]. My problem looks like that:
In a .NET MVC partial view, I'd like to do something like this: <%
I like pretty much of the localization model in asp.mvc. You have the resx-fallback
Hi i'm new at mvc and web develop; I'd like to do something like
I have a model that looks something like this: public class SampleModel { public
With ASP.net MVC I have a Model like so: public class Project { public
I have something like this <h1> I am Text </h1> in asp.net MVC If
I use MVC 3 and EF 4.3.1. I have my class created with POCO
I'm trying to use MVC for a new project after having been around the

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.