Thursday, August 19, 2010

How can i add a tooltip using c# in .NET 2.0 framework?

I'm using c# and want to modify some tooltips. The previous version used worked as this was in 1.1 environment but i now use 2.0. the tooltip is to work like this: http://www.dyn-web.com/dhtml/tooltips/ho...





Thanks for your help in advance...

How can i add a tooltip using c# in .NET 2.0 framework?
The link provided does not work
Reply:ASP.Net 2.0 is a server side language, so a tooltip wold not be functional with it as it would require a page reset. In the past, this was done with javascript, but that can get messy. Here is a way to do it with pure css:





In your stylesheet (or in your style section in your %26lt;head%26gt;) include this:








a.tooltip{position:relative;}


a.tooltip span{display: none; }


a.tooltip:hover span{ /*display just on :hover state*/


display:block;


/*this positions it relative to the link*/


position:absolute; top:1em; left:1em;


/*you can adjust anything under here*/


width:150px; padding:2px; text-decoration:none;


border:1px solid Black; background-color:Gray;}








Now with that set, just use it inside a link for a tooltip:





%26lt;a class="tooltip" href="#"%26gt;Hover over this%26lt;span%26gt;For a tooltip!%26lt;/span%26gt;%26lt;/a%26gt;





Notice that the class must be set to 'tooltip' and that the %26lt;span%26gt; must be inside the %26lt;a%26gt; tags - everything within the span is the tooltip, while everything outside the %26lt;span%26gt; but inside the %26lt;a%26gt; is the words to hover over.


No comments:

Post a Comment