Home C# MVC: Performance and Advantages of MVC Html Helpers vs. Direct HTML in views
Reply: 0

C# MVC: Performance and Advantages of MVC Html Helpers vs. Direct HTML in views

user6513
1#
user6513 Published in September 20, 2018, 4:36 pm

I'd like to know what kind of performance impact Html helpers have on C# ASP.NET MVC views, especially when setting attribute parameters, and what kind of advantages they have overall (why use them?)

With Html Helpers:

<%= Html.TextBox("firstName", Model.FirstName, 
    new { @disabled = "disabled", @class = "myCssClass" }) %>

Direct Html:

<input type="text" class="myCssClass" name="firstName" 
     disabled="disabled" text="<%= Model.FirstName %>"/>

I have quite a few pages that contain between 5 and 15 of such inputs. On top of that Html Helpers allow you to render the form (think Html.BeginForm()) etc. so you potentially end up with 20 or even more Html Helper calls. I think some of them use reflection too, e.g. when you set attributes like the disabled one above.

Isn't there a huge performance impact to do this? Why on earth is it considered better practice to use those helpers? Please somebody give me a good reason :) I'd like to use them but I really fear the performance impact they have.

Are there any real advantages to using Html helpers?

share|improve this question
  • 1
    Very Good Question. Using Html it directly loaded with client machine. But the Helper calling static method render the values from server – Sakthi Karthik May 12 '16 at 10:18

5 Answers 5

active oldest votes
up vote 13 down vote accepted
You need to login account before you can post.

About| Privacy statement| Terms of Service| Advertising| Contact us| Help| Sitemap|
Processed in 0.532823 second(s) , Gzip On .

© 2016 Powered by mzan.com design MATCHINFO