0

I have a C#.Net MVC3 web app. I am adding properties to textboxes (and drop down lists) using the HTML helper functions.

 @Html.TextBox("Date", String.Format("{0:MM/dd/yyyy}", Model.Date),
  new { @class = "datepicker", @title="Date mouse over text" })

Is there a way to format the @title text?

CLARIFICATION: Italics, bolding, coloring....that type of formatting.

Rondel
  • 4,811
  • 11
  • 41
  • 67
MikeTWebb
  • 9,149
  • 25
  • 93
  • 132

3 Answers3

1

this has a general tip on creating a styled tooltip

How to change the style of Title attribute inside the anchor tag?

you'll probably need to create your own htmlhelper that creates the textbox with the tooltip span described in the referenced question

Community
  • 1
  • 1
Bassam Mehanni
  • 14,796
  • 2
  • 33
  • 41
0
@Html.TextBox("Date", String.Format("{0:MM/dd/yyyy}", Model.Date),
  new { @class = "datepicker", 
      title = string.Format("{0}, {1}", "Hello", "World") })

The only reason you use the @ symbol before class is because class is a C# keyword. You would also have to use it for attributes named default, namespace, double, etc.

Title is not a C# keyword. Therefore you do not need to prefix it with the @ symbol.

danludwig
  • 46,965
  • 25
  • 159
  • 237
  • He doesn't need it but with or without it the code is equivalent. So I don't see how this solves the problem (which by the way is not very clear from the OP). – Darin Dimitrov Jan 05 '12 at 15:50
  • Because he's using `string.Format()` on the title... though the OP still hasn't clarified what he means by "format". – GalacticCowboy Jan 05 '12 at 15:59
0

I personally like this one:

jquery.tipTip

You only have to add jquery and tipTip to your page. Then add a short script:

$(function(){
    $(".someClass").tipTip();
});

Then your textbox should be:

@Html.TextBox("Date", String.Format("{0:MM/dd/yyyy}", Model.Date),
  new { @class = "datepicker someClass", @title="Date mouse over text" })
Draganov
  • 375
  • 4
  • 8