www.webdeveloper.com
Results 1 to 5 of 5

Thread: JavaScript Tooltip for ASP:ListBox

  1. #1
    Join Date
    Feb 2012
    Posts
    2

    Angry JavaScript Tooltip for ASP:ListBox

    Hi. I'm a newbie to Javascript and web development.

    I've a long list box which dynamically driven from database using asp:listbox. What I want to do is as displayed in the post at: http://weblogs.asp.net/abdullaabdelh...commentmessage . I wanted to show the complete option name as a tooltip while hovering the mouse over to it. But here it a listbox but not a dropdown menu. Can anyone correct this Fiddle: http://jsfiddle.net/V7u5a/2/ ? Thanks in advance.

  2. #2
    Join Date
    Apr 2010
    Location
    Salem,Ma
    Posts
    623
    the code in your fiddle is C# that adds javascript, not javascript itself. you need to head to the .net forums , http://www.webdeveloper.com/forum/forumdisplay.php?f=28

  3. #3
    Join Date
    Nov 2010
    Posts
    1,088
    why not simply
    Code:
    <html>
    <head>
    <body>
    <select id="ListBox" Width="60px" size="5">
        <option value="1">Item #1</option>
        <option value="2">Item Long Item #2</option>
        <option value="3">Very Long Item #3</option>
        <option value="4">Very Long Long Item #4</option>
        <option value="5">Item #5</option>
        <option value="6">Item #6</option>
        <option value="7">Item #7</option>
    </select>
    <script type="text/javascript">
    opts=document.getElementById("ListBox").getElementsByTagName("option")
    for (var k=0; k<opts.length; k++) {
    opts[k].title=opts[k].text
    }
    </script>
    
    </body>
    </html>
    or am I misunderstanding the question?

  4. #4
    Join Date
    Apr 2010
    Location
    Salem,Ma
    Posts
    623
    Quote Originally Posted by xelawho View Post
    why not simply....
    or am I misunderstanding the question?
    nto at all, Im sure your solution works fine, but he's tryign to embed C# as javascript so I was suggesting he head over to the .net forum so they can 1. show him how to use the example code he has already properly and 2. lt them explain the differences between the 2, then he can decide which direction he wants to go.

    In this secnario, isn't it also technically faster to have .net build the code for each item dynamically server side as opposed to using a loop client side to accomplish the same? I know the performance/page load difference is negligible in this scenario but what if he had 100's of items generated on one page view?

  5. #5
    Join Date
    Feb 2012
    Posts
    2
    Thank you for your replies. Yes xelawho. I was trying to add a tooltip for each and every option in the listbox, because we can't set horigzontal scroll bar to a .net listbox in practice. xelawho's solution fixed the issue. Thank you very much...

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Tags for this Thread

Posting Permissions

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



Recent Articles