...

View Full Version : Javascript tooltip reloading page from server



Vesa
12-01-2006, 12:02 PM
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

nikkiH
12-01-2006, 11:33 PM
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?

Vesa
12-04-2006, 10:16 AM
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:



<%@ 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:



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

nikkiH
12-04-2006, 03:22 PM
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?

Vesa
12-05-2006, 12:34 PM
Yeah, 2.0. This test project is new one, I just pasted code the into it.

My web.config:



<?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

nikkiH
12-05-2006, 04:39 PM
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.

Vesa
12-11-2006, 12:44 PM
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

nikkiH
12-11-2006, 03:16 PM
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?

Vesa
12-27-2006, 12:13 PM
Back after a little break, had a few more urgent projects.


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

Vesa
12-27-2006, 12:33 PM
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

nikkiH
12-27-2006, 03:21 PM
Interesting.
Did you try setting cache settings in the META tags?



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum