asp.net mvc - What's the difference between using @Html.DisplayFor and just use @Model? -
this question has answer here:
- when should use html.displayfor in mvc 2 answers
take account model class property partnername
on it.
in case looks these 2 code produce same results:
@model.partnername @html.displayfor(m => m.partnername)
is there advantages in using 1 against other? because first 1 way more cleaner.
edit , clear i'm talking specific overload.
when display value using @model.partnername
places plain value html without surrounding markup. when use @html.displayfor(m => m.partnername)
invoking displaytemplate render object.
these displaytemplates contain markup make sure value displayed in way. can create custom displaytemplates can always, example, display strings inside fancy boxes borders , colors.
check out article creating custom displaytemplates. http://www.codeguru.com/csharp/.net/net_asp/mvc/using-display-templates-and-editor-templates-in-asp.net-mvc.htm
Comments
Post a Comment