Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 11 of 11
  1. #1
    New to the CF scene
    Join Date
    Dec 2006
    Posts
    6
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Javascript tooltip reloading page from server

    Hi. I'm trying to get my Javascript tooltip to work in ASP.NET 2.0.

    Here's the show-function:

    function ShowTooltip()
    {
    document.getElementById("td0").innerText = "Test";
    x = event.clientX + document.body.scrollLeft -20;
    y = event.clientY + document.body.scrollTop + 10;
    Popup.style.visibility = "visible";
    Popup.style.display="block";
    Popup.style.left = x;
    Popup.style.top = y;
    Popup.style.border = "1px";
    Popup.style.borderColor = "black";
    Popup.style.width = "100px";
    }

    Now, the code does bring the tooltip up, but it also loads the server page every time Popup (which is a div) is mentioned in the code. The load isn't recognized as a postpack, which results in several database queries, slowing down and eventually freezing the entire site. What causes it to do this?

    Thanks,

    --
    Vesa
    Last edited by Vesa; 12-01-2006 at 11:14 AM.

  • #2
    Senior Coder nikkiH's Avatar
    Join Date
    Jun 2005
    Location
    Near Chicago, IL, USA
    Posts
    1,973
    Thanks
    1
    Thanked 32 Times in 31 Posts
    Not anything specifically in this function.

    How can Popup reference a div, when no getElementById is here? Is it a global variable? Does the div it refers to contain an iframe or any other element that performs server requests?

    Can you post more code please?

    Also, does the div contain any images, and are you using caching?
    How did you narrow down the problem to this suspect? Did you remove only suspect code into a complete test page, and trace/debug with Studio?

    If this post contains any code, I may or may not have tested it. It's probably just example code, so no getting knickers in a bunch over a typo, OK? If it doesn't have basic error checking in it, such as object detection or checking if objects are null before using them, put that in there. I'm giving examples, not typing up your whole app for you. You run code at your own risk.
    Bored? Visit
    http://www.kaelisspace.com/

  • #3
    New to the CF scene
    Join Date
    Dec 2006
    Posts
    6
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Yeah, I've done some more debugging, it took the problem apart from the rest of the page so I can post it. Here is Default.aspx:

    Code:
    <%@ Page Language="C#" AutoEventWireup="true"  CodeFile="Default.aspx.cs" Inherits="_Default"   %>
    
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    
    <html xmlns="http://www.w3.org/1999/xhtml" >
    <head>
        <title>Untitled Page</title>
    
    <script language="javascript">
    function ShowTooltip()
    {
    	var Popup = document.getElementById("Popup");
        document.getElementById("td0").innerText = "Testi foo";
        x = event.clientX + document.body.scrollLeft -20;
        y = event.clientY + document.body.scrollTop + 10;
        Popup.style.visibility = "visible";
        Popup.style.left = x;
        Popup.style.top = y;
     }
    
    function HideTooltip()
    {
        Popup.style.visibility = "hidden";
    }
    </script>
    
    </head>
    <body>
        <div>
    <div id="test" onmouseover="ShowTooltip();" onmouseout="HideTooltip();">
    		<span ID="Label9">Test</span>
    </div>
    
    <div id="Popup" style="FONT-SIZE: 8pt; FONT-FAMILY: Verdana; z-index: 109; left: 307px; position: absolute; top: 49px; right: 500px; background-color: #DAF0FF; border-top-width: 1px; border-left-width: 1px; border-left-color: black; border-bottom-width: 1px; border-bottom-color: black; border-top-color: black; border-right-width: 1px; border-right-color: black; width: 100px; visibility: hidden" >
    	<table width="100%" cellpadding="2" cellspacing="2" style="border-right: black 1px solid; border-top: black 1px solid; font-size: 8pt;border-left: black 1px solid; border-bottom: black 1px solid; font-family: Verdana;  background-color: infobackground;" background="#DAF0FF">
    		<tr>
    			<td  id="td0" align="left" style="height: 18px; width: 100%;" ></td>
            </tr>
              
        </table>
    </div>          
        </div>
    </body>
    </html>
    And here is Default.aspx.cs:

    Code:
    using System;
    using System.Data;
    using System.Configuration;
    using System.Web;
    using System.Web.Security;
    using System.Web.UI;
    using System.Web.UI.WebControls;
    using System.Web.UI.WebControls.WebParts;
    using System.Web.UI.HtmlControls;
    
    public partial class _Default : System.Web.UI.Page 
    {
        protected void Page_Load(object sender, EventArgs e)
        {
    		int i = 0;
        }
    }
    The int i is there to host a breakpoint, which still insists on getting hit every time the popup is touched in any way.

    --
    Vesa
    Last edited by Vesa; 12-04-2006 at 09:19 AM.

  • #4
    Senior Coder nikkiH's Avatar
    Join Date
    Jun 2005
    Location
    Near Chicago, IL, USA
    Posts
    1,973
    Thanks
    1
    Thanked 32 Times in 31 Posts
    That's interesting, because I copied this into a new project and set the breakpoint, and the only time it was set off was the initial page load. Mouseovers did not set it off at all, and I did see the tooltip.

    Did you make a whole new project or use an existing one?
    What's in your web.config?
    I'm using 2.0; are you?

    If this post contains any code, I may or may not have tested it. It's probably just example code, so no getting knickers in a bunch over a typo, OK? If it doesn't have basic error checking in it, such as object detection or checking if objects are null before using them, put that in there. I'm giving examples, not typing up your whole app for you. You run code at your own risk.
    Bored? Visit
    http://www.kaelisspace.com/

  • #5
    New to the CF scene
    Join Date
    Dec 2006
    Posts
    6
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Yeah, 2.0. This test project is new one, I just pasted code the into it.

    My web.config:

    Code:
    <?xml version="1.0"?>
    <!-- 
        Note: As an alternative to hand editing this file you can use the 
        web admin tool to configure settings for your application. Use
        the Website->Asp.Net Configuration option in Visual Studio.
        A full list of settings and comments can be found in 
        machine.config.comments usually located in 
        \Windows\Microsoft.Net\Framework\v2.x\Config 
    -->
    <configuration>
    	<appSettings/>
    	<connectionStrings/>
    	<system.web>
    		<!-- 
                Set compilation debug="true" to insert debugging 
                symbols into the compiled page. Because this 
                affects performance, set this value to true only 
                during development.
            -->
    		<compilation debug="true"/>
    		<!--
                The <authentication> section enables configuration 
                of the security authentication mode used by 
                ASP.NET to identify an incoming user. 
            -->
    		<authentication mode="Windows"/>
    		<!--
                The <customErrors> section enables configuration 
                of what to do if/when an unhandled error occurs 
                during the execution of a request. Specifically, 
                it enables developers to configure html error pages 
                to be displayed in place of a error stack trace.
    
            <customErrors mode="RemoteOnly" defaultRedirect="GenericErrorPage.htm">
                <error statusCode="403" redirect="NoAccess.htm" />
                <error statusCode="404" redirect="FileNotFound.htm" />
            </customErrors>
            -->
    	</system.web>
    </configuration>
    --
    Vesa

  • #6
    Senior Coder nikkiH's Avatar
    Join Date
    Jun 2005
    Location
    Near Chicago, IL, USA
    Posts
    1,973
    Thanks
    1
    Thanked 32 Times in 31 Posts
    I'm pretty much stuck as to why you're seeing this loading behavior, as I'm not.

    So, let's look at everything

    Browser / version?
    -- I'm using MSIE 6.0.29.00.2180

    IIS version?
    -- I have IIS 5.1

    Web server OS?
    -- I have Win XP SP2

    ASP version:
    -- I have v2.0.50727

    Your IIS has a global configuration for ASP.NET. Check that for any oddness. Check your web site properties for the version it is using as its default and make sure it's set to 2.0.

    Also, add an if not postback in that page load, and see if it still fires. It should not, but you can trace which component is firing if it does.

    Did you know you don't have a form on this test page? One and only one form runat=server is required in all asp.net pages. If you don't have that for some reason, yet you're auto wiring events, it might be confusing your server.

    If this post contains any code, I may or may not have tested it. It's probably just example code, so no getting knickers in a bunch over a typo, OK? If it doesn't have basic error checking in it, such as object detection or checking if objects are null before using them, put that in there. I'm giving examples, not typing up your whole app for you. You run code at your own risk.
    Bored? Visit
    http://www.kaelisspace.com/

  • #7
    New to the CF scene
    Join Date
    Dec 2006
    Posts
    6
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Quote Originally Posted by nikkiH View Post
    I'm pretty much stuck as to why you're seeing this loading behavior, as I'm not.
    Pretty amazing, huh?

    Browser / version?
    -- I'm using MSIE 6.0.29.00.2180
    Same here.

    IIS version?
    -- I have IIS 5.1
    Same here.

    Web server OS?
    -- I have Win XP SP2
    Same here.

    ASP version:
    -- I have v2.0.50727
    Same here.

    Also, add an if not postback in that page load, and see if it still fires. It should not, but you can trace which component is firing if it does.
    It fires. It isn't a postback that loads the page. If it were, it would be a much smaller problem anyway.

    Did you know you don't have a form on this test page? One and only one form runat=server is required in all asp.net pages. If you don't have that for some reason, yet you're auto wiring events, it might be confusing your server.
    I seem to have lost it when I did testing, it being there doesn't help.

    --
    Vesa

  • #8
    Senior Coder nikkiH's Avatar
    Join Date
    Jun 2005
    Location
    Near Chicago, IL, USA
    Posts
    1,973
    Thanks
    1
    Thanked 32 Times in 31 Posts
    OK, really stupid question, but I'm out of ideas. LOL
    Browser caching turned off and there's an image in the page somewhere?
    What are your caching settings, and do you see this behavior in other browsers on other people's computers?
    Do you have a live link anywhere?

    If this post contains any code, I may or may not have tested it. It's probably just example code, so no getting knickers in a bunch over a typo, OK? If it doesn't have basic error checking in it, such as object detection or checking if objects are null before using them, put that in there. I'm giving examples, not typing up your whole app for you. You run code at your own risk.
    Bored? Visit
    http://www.kaelisspace.com/

  • #9
    New to the CF scene
    Join Date
    Dec 2006
    Posts
    6
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Back after a little break, had a few more urgent projects.

    Quote Originally Posted by nikkiH View Post
    OK, really stupid question, but I'm out of ideas. LOL
    Browser caching turned off and there's an image in the page somewhere?
    No images. Nothing but the text in my test version.

    What are your caching settings, and do you see this behavior in other browsers on other people's computers?
    Do you have a live link anywhere?
    The problem here is I'm developing this for a customer and I can't really spread anything.

    Oooooooookay.

    Setting IE cache from checking for new version from every visit to automatic, the problem vanished. But I'm not sure if that is applicable, we have to use the setting our customer uses for several reasons. I'll have to see what I can do about this.

    --
    Vesa

  • #10
    New to the CF scene
    Join Date
    Dec 2006
    Posts
    6
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Quote Originally Posted by Vesa
    Setting IE cache from checking for new version from every visit to automatic, the problem vanished.
    Except it didn't.

    It did at first, but then it didn't again.

    I'm starting to see that caching is the problem. Somehow IE imagines that it has to fetch the page again.

    And yes, I have to use IE, and I can't even update to IE7 yet.

    --
    Vesa

  • #11
    Senior Coder nikkiH's Avatar
    Join Date
    Jun 2005
    Location
    Near Chicago, IL, USA
    Posts
    1,973
    Thanks
    1
    Thanked 32 Times in 31 Posts
    Interesting.
    Did you try setting cache settings in the META tags?

    If this post contains any code, I may or may not have tested it. It's probably just example code, so no getting knickers in a bunch over a typo, OK? If it doesn't have basic error checking in it, such as object detection or checking if objects are null before using them, put that in there. I'm giving examples, not typing up your whole app for you. You run code at your own risk.
    Bored? Visit
    http://www.kaelisspace.com/


  •  

    Posting Permissions

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