I have the following property in my QuoteSalesRep
class:
[Display(Name = "Commision %")]
[UIHint("Percentage")]
public decimal CommisionPercentage { get; set; }
I would like to create an Editor template that would render anything with the [UIHint("Percentage")]
like so:
Under Views/Shared/EditorTemplates I added Percentage.cshtml. I currently have the following code:
@model decimal
<div class="input-group">
<input type="text" class="form-control">
<span class="input-group-addon">%</span>
</div>
I am new to working with templates. What do I need to do to correct the above code so it renders the input-group properly for any property tagged with [UIHint("Percentage")]?
I think all you're missing is a generic way of generating the text input:
@Html.TextBox("", ViewData.TemplateInfo.FormattedModelValue.ToString(), new { @class = "form-control" })