So, I've an obj structure something like below.
ComparedObject:
public List<string> Objs { get; set; }
public string PropName { get; set; }
ModelObj:
public List<ComparedObject> CObjs { get; set; }
I've a scenario in which I would need to loop through "CObjs" and render Comparison table of List<string>
object whose lengh would be 3 records (in a row).
I've achieved this using a Custom HTML Helper to make it generic enough to be used in other screens. But, I was told that Custom Display Template would be faster and better at performance in this scenario.
Please explain what is the best option and why.
Thanks in advance!!
DisplayTempate
In order to display the template you need to use theDisplayFor()
method which is a html helper extension method as well – user3559349 May 8 '15 at 11:13DisplayTemplate
you need to use@Html.DisplayFor()
which is a html helper.DisplayFor()
in turn calls theTemplateHelper
method to get theViewEngine
and find the template and eventually render it based on all the html helper methods in the template. Its all so fast I have not bothered to run performance tests but usingDisplayFor()
would almost certainly be slower than using your own helper - but of course that depend on the code in your helper. – user3559349 May 8 '15 at 11:59