Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is the difference between Html.Label and Html.Display?

What is the difference between Html.Label and Html.Display?

like image 635
Yousuf Tafhim Avatar asked Feb 28 '11 04:02

Yousuf Tafhim


1 Answers

Html.Label() renders HTML markup <label /> that can be used for a model entity's attrubute.

For eg,

<%= Html.Label("Full Name", Model.FullName) %>

would render

 <label for="FullName">Full Name </label>

Html.Display() on the other hand renders HTML markup for entire entity based on specified templates. For eg. if you have a Person entity with multiple attributes, you define a template with markup as to how to render a Person and Html.Display() uses that template to render Person objects across views. Phil Haack has an excellent post on display templates.

like image 91
Bala R Avatar answered Oct 11 '22 07:10

Bala R