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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T05:49:03+00:00 2026-06-14T05:49:03+00:00

I am looking for best practices for design razor view with MVC. which would

  • 0

I am looking for best practices for design razor view with MVC.

which would be better option:

HtmlHelper extension methods

    @Html.TextBox("txtName")

or
write the html directly

    <input type"text" id="txtName" name="txtName" />

I found 2 diferent links.
The first one http://blogs.msdn.com/b/aspnetue/archive/2010/09/17/second_2d00_post.aspx says DO use HTMLHelper extension methods.
and the second one http://codeclimber.net.nz/archive/2009/10/27/12-asp.net-mvc-best-practices.aspx says 10 – Write HTML each time you can

so i am a little cofused

  • 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-14T05:49:04+00:00Added an answer on June 14, 2026 at 5:49 am

    Even the name HtmlHelper should already give you a hint whether you should use it or not. Do you want help? If not, just write html from the scratch. It does not really matter how the html was generated: from the scratch or using html helper. What matter is that it was generated with correct names of the inputs so that model binder can bind these inputs to the model.

    For example, suppose you have the following Model that will be passed to the view and that will be received on the POST:

    public class SomeModel
    {
        public Customer Customer { get; set; }
    }
    
    public class Customer
    {
        public int Id { get; set; }
        public string FirstName { get; set; }
        public string LastName { get; set; }
    }
    

    In order to make sure that your inputs will be binded to the model you need three inputs on your page:

    <input type="hidden" id="whatever" name="Customer.Id" /> 
    <input type="text" id="whatever" name="Customer.FirstName" />
    <input type="text" id="whatever" name="Customer.LastName" />
    

    Having this html markup will assure proper model minding. However, you can achieve this markup by using HtmlHelpers, which is a lot easier:

    @Html.HiddenFor(m => m.Customer.Id)
    @Html.TextBoxFor(m => m.Customer.FirstName)
    @Html.TextBoxFor(m => m.Customer.LastName)
    

    This will not only give you proper name attributes on every input, but also assign id attributes accordingly so you don’t have to do that all by your self.


    It appears that the author from the second article suggests to never use HtmlHelpers for two reasons:

    1. the learning purposes: I assume by saying “web developers have to be
      comfortable writing HTML” he means that developer should know
      exactly what html markup is required for proper model binding.
    2. the fear of black box: It seem that author is afraid that improper html
      markup will be generated by using HtmlHelpers or he just does not
      know what html will be generated.

    I disagree with his phrase: “HtmlHelpers whose only reason of living is hiding the HTML away”. I’d rather say “HtmlHelpers whose only reason of living is helping writing Html markup”


    Summary:
    HtmlHelpers help you write proper html markup, which is why I suggest you using it.

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

Sidebar

Related Questions

I am looking for ways / best practices on testing methods defined in an
I'm looking for info on best practices for a fire and forget asp.net mvc
Looking for some best practices of UI list on iPhone which has item add/modify/delete
I am looking for best practices/design patterns for keeping JavaScript in external JS files/bottom
Best Practices to design multi-language web site database. Technologies employed here are ASP.NET MVC
I'm looking for a book/site/tutorial on best practices for relational database design, tuning for
I am looking for any resources that gives examples of Best Practices, Design patterns
I am looking for some design best practice or heuristic to address performance issues
I am looking for best practices of avoiding constructor injection overuse. For example I
I'm looking for best practices here. Sorry. I know it's subjective, but there are

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.