How do I use the html 'title' attribute with Html.Encode()?

Posted by Kai on Stack Overflow See other posts from Stack Overflow or by Kai
Published on 2010-05-26T22:46:24Z Indexed on 2010/05/26 22:51 UTC
Read the original article Hit count: 273

Filed under:
|

Hello,

I've been tryin to find an example of the syntax for getting an html 'title' for a string when using Html.Encode(). I want to display the full name in the mouseover title, if it's too long.

Is there a way to do this without wrapping the string in a < span >, i.e.

 <span title = "<%=Html.Encode(model.Name) %>">   //displays the full name on mouseover
 <%=Html.Encode(model.Name.Substring(0, 10))%>... //displays the name up to a max length
 </span>

Or should I just do it this way?

Thanks!

© Stack Overflow or respective owner

Related posts about ASP.NET

Related posts about html