Results 1 to 6 of 6

Thread: [RESOLVED] how to create tooltip on mouse over

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Jun 2007
    Posts
    241

    Resolved [RESOLVED] how to create tooltip on mouse over

    Hi,

    How to create a tooltip on mouse over in asp.net or javascript?
    I have a button control search. while i mouse over in the button it shows please search message in tooltip. Is it possible?

    Thanks
    Failing to plan is Planning to fail

  2. #2
    Learning .Net danasegarane's Avatar
    Join Date
    Aug 2004
    Location
    VBForums
    Posts
    5,853

    Re: how to create tooltip on mouse over

    Add a tool tip using the tool tip property

    Code:
    <asp:Button  runat="server" Text="Submit" ID="ButtonSubmit" ToolTip="Search"  />
    Or place fancy tool tip using div tags as shown here
    Please mark you thread resolved using the Thread Tools as shown

  3. #3
    PowerPoster gep13's Avatar
    Join Date
    Nov 2004
    Location
    The Granite City
    Posts
    21,963

    Re: how to create tooltip on mouse over

    Or, if you want a really "flashy" version, and have a couple dollars, you could use this one:

    http://www.aspnettooltip.com/

    Gary

  4. #4
    Frenzied Member avrail's Avatar
    Join Date
    Mar 2006
    Location
    Egypt, Cairo
    Posts
    1,221

    Re: how to create tooltip on mouse over

    hay,
    Code:
    Button1.ToolTip = "search";
    You Don't Have to Rate Me.
    I'm Not a Civilized Man I'm the Civilization it self
    White or Black, Living or Dieing and 0 or 1 that's MY life
    iam an Object in Object Oriented Life
    my blog : http://refateid.blogspot.com/
    twitter :@avrail
    010011000111010101110110001000000100110101111001001000000101000001100011

  5. #5
    PowerPoster motil's Avatar
    Join Date
    Apr 2009
    Location
    Tel Aviv, Israel
    Posts
    2,143

    Re: how to create tooltip on mouse over

    Hi
    well in case you're using jQuery I Also needed tooltip few days ago, i searched some already made tooltip and i indeed found some neat ones but the problem was they all weight to big for tool tips 70-80kb js file

    http://www.webdesignbooth.com/15-jqu...endly-tooltip/


    if you like me want a not to fancy tooltip but still looks good here is the plug-in I made for jQuery few days ago and the code weight less then 1kb.

    CSS: (you can modify it as you wish)
    Code:
    .CPToolTip{position:relative;-moz-border-radius:5px;-webkit-border-radius:5px;border:1px solid #919292;display:none;background:#fff;direction:rtl;padding:3px 3px 3px 3px;font-size:11px;z-index:2701}
    js
    Code:
    $.fn.CPToolTip = function (options) {
        var defaults = {
            width: 150,
            textAlign: 'center',
            topOffset: 0,
            leftOffset: 0
        }
    
        var options = $.extend(defaults, options);
        var me = $(this);
        var elements = $('[title]', this);
        if (elements.length == 0) elements = $(this)
        $(elements, me).each(function () {
    
            var saveAttr = $(this).attr('title')
            $(this).unbind('mouseenter mouseleave')
            $(this).hover(function () {
                var offset = $(this).offset();
                var left = (offset.left + ($(this).width() / 2)) - ((options.width / 2) + options.leftOffset);
                var text = $(this).attr('title')
                var arrowLeft = (options.width / 2) - 9;
                $('<div  class="CPToolTip" style="width:' + options.width + 'px;position:absolute;left:' + left + 'px;top:' + top + 'px;text-align:' + options.textAlign + ';line-height:' + options.height + 'px">' + text + '<img class="CPToolTipArrow" src="/Graphics/tooltiparrow.png" style="left:' + arrowLeft + 'px"></div>').appendTo('body')
                .fadeTo(0, 0.9, function () {
                    if (jQuery.browser.msie) {
                        $('.CPToolTip').get(0).style.removeAttribute('filter');
                    }
                })
    
                $('.CPToolTip').css({ 'top': (offset.top - ($('.CPToolTip').height()) - 17) - options.topOffset + 'px' });
                $(this).attr('title', '');
    
            }, function () {
                $('.CPToolTip').attr('title', saveAttr).remove();
                $(this).attr('title', saveAttr);
    
            });
        });
    }
    just set the title attributes to the elements you wish to have tooltip and on page load:

    Code:
     $('body').CPToolTip({ width: 60, topOffset: 5, leftOffset: 0 });
    // or
     $('#MyContainer').CPToolTip({ width: 60, topOffset: 5, leftOffset: 0 });
    // or 
     $('.MyClass').CPToolTip({ width: 60, topOffset: 5, leftOffset: 0 });
    
    // or any other jQuery selector.
    my tool tip use CSS3 rounded corners property so it's look better in supported browsers.


    i attached the img needed for my tooltip plugin
    Attached Images Attached Images  
    Last edited by motil; Sep 17th, 2010 at 04:23 AM.
    * Rate It If you Like it

    __________________________________________________________________________________________

    "Programming is like sex: one mistake and you’re providing support for a lifetime."

    Get last SQL insert ID

  6. #6

    Thread Starter
    Addicted Member
    Join Date
    Jun 2007
    Posts
    241

    Re: how to create tooltip on mouse over

    hi

    Thanks. I got it :-)
    Failing to plan is Planning to fail

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width