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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T02:22:57+00:00 2026-05-24T02:22:57+00:00

I hate that ASP.NET html helpers generates name and id attributes in the same

  • 0

I hate that ASP.NET html helpers generates name and id attributes in the same case as the POCO properties.

Most developers typically use lower case values for name and id but I cannot seem to find a way to accomplish this in ASP.NET MVC.

A look through the source shows that there is no way to override this functionality, but I could be wrong.

Is this at all possible?

EDIT:
I’ll be more specific, with examples of what I am talking about since there seems to be some confusion.

My model looks like this:

public class Customer
{
    public string FirstName { get; set; }
    public string LastName { get; set; }
}

In my view I use Html herlpers like so:

@Html.InputFor(m => m.FirstName)

This generates markup that looks like this:

<input type="text" name="FirstName" id="FirstName" value="" />

I hate that the FirstName property is capitalized. In a perfect world, I would like a way to override the generation of this attribute value such that I can make it say “firstName” instead.

I do not want to change the POCO property names to be lower case. So much of the ASP.NET MVC framework is extensible and customizable – is this something that is not?

  • 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-24T02:22:58+00:00Added an answer on May 24, 2026 at 2:22 am

    Display(Name = "abc") attribute changes the output of Html.LabelFor and when we use EditorForModel and DisplayForModel. it does not affect how Html.TextBoxFor is rendered and it is not supposed to change the way id or name attributes of form fields are rendered. if you really need to do so you have to write your own html helper like

    public static MvcHtmlString LowerTextBoxFor<TModel,TProperty>(this HtmlHelper<TModel> html, Expression<Func<TModel,TProperty>> expr)
            {
                StringBuilder result = new StringBuilder();
                TagBuilder tag = new TagBuilder("input");
                tag.MergeAttribute("type","text");
                var lowerPropertyName = ExpressionHelper.GetExpressionText(expr).ToLower();
                tag.MergeAttribute("name",lowerPropertyName);
                tag.MergeAttribute("id",lowerPropertyName);
                result.Append(tag.ToString());
                return new MvcHtmlString(result.ToString());
            }
    

    you can use this html helper in view like.

    @Html.LowerTextBoxFor(x=>x.Property1)
    

    Be aware that this example just generate just id and name attribute. you will have to code for other attributes like unobtrusive attributes and even other overloads of this method to effectively use it

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

Sidebar

Related Questions

I have an ASP.NET MVC web application that makes REST style web service calls
i have sql that uses FOR XM RAW to generate xml for my asp.net
I hate the JavaBeans pattern with a passion that burns like the fire of
I have a small to medium project that is in C++/CLI. I really hate
I hate case sensitivity in databases, but I'm developing for a client who uses
I am wondering if there is a way to make ASP.NET controls play nicely
I've been playing around with ASP.NET MVC with a site containing a Master Page.
Background: I'm using jquery blockui 2.31 on jquery 1.3.2, on ASP.NET 2.0. I'm using
We have a legacy ASP.net powered site running on a IIS server, the site
What is the best way to rotate a image in asp.net I did use

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.