I have a simple field form
<div class="field fade-label">
@Html.LabelFor(model => model.Register.UserName)
@Html.TextBoxFor(model => model.Register.UserName)
</div>
and this results in:
<div class="field fade-label">
<label for="Register_UserName">Username (used to identify all services, from 4 to 30 chars)</label>
<input type="text" value="" name="Register.UserName" id="Register_UserName">
</div>
but I want that LabelFor code append a <span> inside so I can end up having:
<label for="Register_UserName">
<span>Username (used to identify all services, from 4 to 30 chars)</span>
</label>
How can I do this?
All examples use EditorTemplates but this is a LabelFor.
You’d do this by creating your own HTML helper.
http://www.asp.net/mvc/tutorials/creating-custom-html-helpers-cs
You can view the code for LabelFor<> by downloading the source for ASP.Net MVC and modify that as a custom helper.
Answer added by balexandre