Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Web Programming > JavaScript > Javascript
|
Javascript General Javascript discussions.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Javascript section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old June 6th, 2007, 06:33 AM
Authorized User
 
Join Date: May 2007
Posts: 30
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to swifty_programmer
Default Acces dynamicly(with JS) made <div> in code

Hi,
A've appended a piece of HTML code (wrapped around a <DIV>) with JavaScript for use of a tooltip.
This tooltip appears on "onmouseover" a row and dissapears on "onmouseout" of the row. In javascript a catches those events and displays tooltip or hides it.
When the users select criteria's with no result comming from the same page WITH result the tooltip stays displayed because the row "onmouseover" occured in the fraction of a second the dropdownlist disapeared and the mousecursor is inevitable over a row WITH data, then the new pages load but of course the "onmouseout" of the row never occured and the tooltip still displays the data.
So I want to hide this <div> element when there are no rows in the datalist. Therefor I must acces to this <DIV> element in my code behind but this <DIV> element is only dynamicly created at runtime not at design time.
If someone please can help me...
Thx!
 
Old June 6th, 2007, 08:15 AM
joefawcett's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 3,074
Thanks: 1
Thanked 38 Times in 37 Posts
Default

There are a few options. One would be to assign it a custom attribute, such as isTooltip="true" using setAttribute when you create it. When your page loads and you know there are none to display loop through all the divs using document.getElementsByTagName and then test if getAttribute("isTooltip") returns anything. If it does set the style.display to "none" or remove the div entirely.

--

Joe (Microsoft MVP - XML)
 
Old June 6th, 2007, 12:07 PM
Authorized User
 
Join Date: May 2007
Posts: 30
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to swifty_programmer
Default

Thx for th reply, but it's not quite a useful answer.
Let me explain myself:
I add
 row.Attributes.Add("onmouseover", "JSfunction_that_makes_tooltip");
and
  row.Attributes.Add("onmouseout", "JSfunction_that_hides_tooltip");
for each row in the DataList.OnDataBinding() event.

The problem is that the whole tooltip is made in javascript (no reference what so ever in my code or design.)
The DropDownList used to select a criteria is located just above the DataList so when you choose a different criteria in de DropDownList the list disapears for 0.5 of a second and the "onmouseover" event is fired in javascript of the row that was just underneath the selected dropdownlist item.
Now the real problem is that when the DataList has no rows. The tooltip still displays the previous row-data of the previous DataList.

So I'm looking for a way to say in my C#-code that:
if(DataList.Rows.Count <= 0) ? "tooltip".visible=false: "tooltip".visible = true;
This would be very simple if I would be able to access that <DIV> in my C#.

 
Old June 19th, 2007, 12:36 AM
Authorized User
 
Join Date: Jun 2007
Posts: 39
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Dear swifty

You are programming in .Net, so you can use Panel control instead of creating your tooltip DIV element dynamically on client side. Use a panel control as a tooltip and give it an id (like 'tooltip') so you could access it in your C# code behind. As user changes drop down list, you can set panel's visibility easily as below :

if(DataList.Rows.Count <= 0) ? tooltip.visible=false: tooltip.visible = true;





Similar Threads
Thread Thread Starter Forum Replies Last Post
Javascript with <div> aware Javascript How-To 3 August 25th, 2005 05:57 AM
<style> tags in a <body> vs. <div> bcat BOOK: Beginning CSS: Cascading Style Sheets for Web Design ISBN: 978-0-7645-7642-3 1 March 27th, 2005 08:50 AM
sizeable <div> johnjohn Javascript How-To 1 December 8th, 2004 08:28 PM
scrolling <DIV> anshul Javascript How-To 12 August 4th, 2004 09:51 AM
<A><DIV><TABLE></DIV></A> anshul HTML Code Clinic 2 July 17th, 2004 02:17 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.