1
I created a custom attribute called Tooltip. I would like to add tooltips to any property that has this attribute.
Example:
In my model I have the following property:
[Required, ToolTip("Neste campo você deve inserir um nome.")]
public string Nome { get; set; }
And in the view:
@Html.TextBoxFor(m => m.Nome, new { @class = "form-control" })
Rendering:
<input class="form-control" data-val="true" data-val-required="O campo Nome é obrigatório." id="Nome" name="Nome" type="text" value="">
I’d like it to render with the bootstrap tooltip attributes, like this:
<input data-toggle="tooltip" data-original-title="Neste campo você deve inserir um nome." class="form-control" data-val="true" data-val-required="O campo Nome é obrigatório." id="Nome" name="Nome" type="text" value="">
Any suggestions?
Have you seen this link? http://stackoverflow.com/questions/3707997/asp-net-mvc-extending-dataannotions
– Jhonathan
How you created this attribute?
– Randrade
@Jhonatan I really wanted to use the default Textboxfor without creating a new helper or Xtension, but I’m not sure if it can be done.
– Eduardo Moreira
@Randrade identical to the chosen answer on the Jhonathan link
– Eduardo Moreira
@Eduardomoreira , I believe that without any customization would not be possible, at least I do not know.
– Jhonathan
@Jhonatan is, apparently there is not. as this is a somewhat advanced topic for me that I’m starting I ended up traveling in mayonnaise. but thanks for the help.
– Eduardo Moreira