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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T11:03:45+00:00 2026-05-24T11:03:45+00:00

By default, MVC’s input html helpers generate id and name with the same value.

  • 0

By default, MVC’s input html helpers generate “id” and “name” with the same value. In my case i do not need the id, and when i do, I always enter a custom value. Auto generating unnecessary id’s increases the document size, and makes me nerves, because i might be using the same id in my CSS or JavaScript code.

Can i alter the default behavior of the html helpers, so the id is not generated unless manually defined.

I know that i can tell the helpers not to generate an id by passing new { id = "" }, but this approach is not very convenient for large, data-entry-type applications.

Is there an easy way to alter this behavior, or do i need to write custom html helpers?

  • 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-24T11:03:46+00:00Added an answer on May 24, 2026 at 11:03 am

    use,

    Html.TextBoxFor(m => m.Text).RemoveNameIdAttribute()
    
    public static MvcHtmlString RemoveNameIdAttribute(this MvcHtmlString helper)
    {
                if (helper == null)
                throw new ArgumentNullException();
            var element = helper.ToString();
            var regex = new Regex("(id|name)[^'\"]*['\"][^'\"]*['\"]",RegexOptions.IgnoreCase | RegexOptions.Compiled);
            return MvcHtmlString.Create(regex.Replace(element, ""));
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

By default the MVC Preview 5 web project comes with a HomeController.vb class. This
I'm trying to connect my stock standard, default ASP.NET MVC (web) application to the
I want to go beyond the default error handling given in ASP mvc. I
In ASP MVC (RC 1), how can I change the default template for ValidationSummary?
The default rails XML builder escapes all HTML, so something like: atom_feed do |feed|
I am using Forms Authentication for the default MVC site, and i also have
I've been playing around with the default MVC 1 site, adding some fields to
Simple question. I know that in the default MVC application in Visual Studio, you
The default scaffolded views generated by ASP.NET MVC 2 contain links such as: <%:
I'm using MVC 2 and the default view engine to return .ascx partial views

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.