I'd like to create template for string, that will include label, textbox with watermark and validation message for registration form. In addition, I'd like to add notice (eg. star), that the field is required by getting it from model.
So far I have created file string.cshtml in ~/Views/Account/EditorTemplates containing this:
<span class="editor-label>@Html.Label(ViewData.ModelMetadata.Watermark)</span>
<span class="editor-field">@Html.TextBox("", ViewData.TemplateInfo.FormattedModelValue, new { placeholder = ViewData.ModelMetadata.Watermark })</span>
<span class="error_message">@Html.ValidationMessage(ViewData.ModelMetadata.PropertyName)</span>
Model looks like this:
[Required]
[DataType(DataType.Text)]
[Display(Prompt = "First name")]
public string FirstName { get; set; }
And in view I call it as follows:
@Html.EditorFor(m => m.FirstName)
Does anyone have any idea, where do I go wrong?