Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

asp.net mvc c# tooltip

what is the best and most simplest way to create tooltip text for textboxes

like image 881
maztt Avatar asked Jul 31 '10 11:07

maztt


Video Answer


2 Answers

With JavaScript and probably with a framework like jQuery that fits very well with ASP.NET MVC. Using the framework means that someone's alread done the hard work and written a plugin for it!

  • qtip
  • tooltip
  • List of some tooltip plugins

There is of course the title attribute on text inputs that shows as a popup tip in some browsers.

like image 198
Russ Cam Avatar answered Sep 28 '22 03:09

Russ Cam


I found this to be the simplest and easy to maintain approach:

  1. Create description using data annotation for the property of your model Example:

    [Display(Name="MyTextBox", Description = "Title for your entry")] public string MyTextBox{ get; set; }

  2. Then in your view access the description above using:

    @Html.TextBoxFor(model => model.MyTextBox, new { title = ModelMetadata.FromLambdaExpression(model => model.MyTextBox, ViewData ).Description })

like image 22
user3885927 Avatar answered Sep 28 '22 05:09

user3885927