For Simple tags in MVC Razor do you prefer to use simple HTML or use extension methods eg
<label for="male">Male</label>
Or
@Html.Label("male", "Male")
I feel it is sometime more easier to use the simple HTML. Extension methods make sense when you want to do some custom code.
Depends. If the
male
element you are associating this label to is rendered with a html helper like:@Html.TextBoxFor(x => x.Male)
then I would use aHtml.LabelFor
and keep the lambdas and strong typing. Also I would never use:I would use a view model and a strongly typed version:
and I would decorate my view model property with the
[DisplayName]
attribute so that I can control message on my view model:So there are like many different possible scenarios. I could also sometimes simply use static HTML and no helpers (currently can't think of such scenario but I am sure it exists).
You could use DisplayFor. It's another way to show your data.