473,287 Members | 1,866 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,287 software developers and data experts.

master pages and scrollTop = 0

Hey all,
I'm building out my first project using asp.net v2.0 master pages. It seems
that when you use master pages and try to reference document.body.scrollTop
it allways = zero/0. The same code works in a regular .htm file.

Has anyone else seen this?
Anyone know how to get the body.scrollTop property using masterpages.
Thanks for any help
Andy
May 16 '06 #1
9 3917
Hi Andy,

Could you show us the master page code? When you view the rendered source,
do you see something different than expected?

Ken

"Andy" <An**@discussions.microsoft.com> wrote in message
news:C6**********************************@microsof t.com...
Hey all,
I'm building out my first project using asp.net v2.0 master pages. It
seems
that when you use master pages and try to reference
document.body.scrollTop
it allways = zero/0. The same code works in a regular .htm file.

Has anyone else seen this?
Anyone know how to get the body.scrollTop property using masterpages.
Thanks for any help
Andy

May 17 '06 #2
Hi Ken,
Here's my master page code:
Thanks for any help

<%@ Master Language="C#" AutoEventWireup="true"
CodeFile="PublicSite.master.cs" Inherits="PublicSite" %>
<%@ Register Src="UserControls/TopNavHome.ascx" TagName="TopNavHome"
TagPrefix="uc2" %>
<%@ Register TagPrefix="cms"
Namespace="Microsoft.ContentManagement.WebControls "
Assembly="Microsoft.ContentManagement.WebControls, Version=5.0.1200.0,
Culture=neutral, PublicKeyToken=31bf3856ad364e35" %>
<%@ Register Src="Console/DefaultConsole.ascx" TagName="DefaultConsole"
TagPrefix="uc1" %>
<!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 runat="server">
<title></title>
<cms:RobotMetaTag runat="server"></cms:RobotMetaTag>
<meta name="Description" content="" id="MetaDesc" runat="server" />
<meta name="Keywords" content="" id="MetaKey" runat="server" />
<link href="StyleSheets/PublicSite.css" rel="stylesheet" type="text/css"
/>
</head>
<body onclick="PositionAuthoringConsole();">
<form id="form1" runat="server">
<div id="testdiv">
<table border="0" cellpadding="0" cellspacing="0" width="770"
class="PageBorder">
<tr class="TopNavRow">
<td>
<uc2:TopNavHome ID="TopNavHome1" runat="server" />
<%--TopNavControl--%>
</td>
</tr>
<tr>
<td valign="top">
<table width="100%" border="0" cellpadding="0"
cellspacing="0">
<tr>
<td valign="top" class="LeftNavArea">
<%--SearchControl--%><br />
<%--LeftNavControl--%>
</td>
<td valign="top" class="BodyBox">
<%--PageTitleControl--%>
<span class="Content">
<asp:contentplaceholder
id="BodyContentPlaceHolder" runat="server" />
</span>
</td>
</tr>
</table>
</td>
</tr>
<tr>
<td class="Footer">
<%--FooterControl--%>
</td>
</tr>
</table>
<br />
<uc1:DefaultConsole ID="DefaultConsole1" runat="server" />

</div>

</form>

<!-- The following will allow the WBC to autoposition and "float" -->
<script language="javascript" type="text/javascript">

function PositionAuthoringConsole() {
alert("testme: " + window.document.body.scrollTop);
}
</script>
</body>
</html>
"Ken Cox [Microsoft MVP]" wrote:
Hi Andy,

Could you show us the master page code? When you view the rendered source,
do you see something different than expected?

Ken

"Andy" <An**@discussions.microsoft.com> wrote in message
news:C6**********************************@microsof t.com...
Hey all,
I'm building out my first project using asp.net v2.0 master pages. It
seems
that when you use master pages and try to reference
document.body.scrollTop
it allways = zero/0. The same code works in a regular .htm file.

Has anyone else seen this?
Anyone know how to get the body.scrollTop property using masterpages.
Thanks for any help
Andy


May 17 '06 #3
Hi Andy,

I tried your code and I get zero for the value of the body. What's the
expected value?

What object are you trying to test?

Ken
"Andy" <An**@discussions.microsoft.com> wrote in message
news:7E**********************************@microsof t.com...
Hi Ken,
Here's my master page code:
Thanks for any help

<%@ Master Language="C#" AutoEventWireup="true"
CodeFile="PublicSite.master.cs" Inherits="PublicSite" %>
<%@ Register Src="UserControls/TopNavHome.ascx" TagName="TopNavHome"
TagPrefix="uc2" %>
<%@ Register TagPrefix="cms"
Namespace="Microsoft.ContentManagement.WebControls "
Assembly="Microsoft.ContentManagement.WebControls, Version=5.0.1200.0,
Culture=neutral, PublicKeyToken=31bf3856ad364e35" %>
<%@ Register Src="Console/DefaultConsole.ascx" TagName="DefaultConsole"
TagPrefix="uc1" %>
<!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 runat="server">
<title></title>
<cms:RobotMetaTag runat="server"></cms:RobotMetaTag>
<meta name="Description" content="" id="MetaDesc" runat="server" />
<meta name="Keywords" content="" id="MetaKey" runat="server" />
<link href="StyleSheets/PublicSite.css" rel="stylesheet"
type="text/css"
/>
</head>
<body onclick="PositionAuthoringConsole();">
<form id="form1" runat="server">
<div id="testdiv">
<table border="0" cellpadding="0" cellspacing="0" width="770"
class="PageBorder">
<tr class="TopNavRow">
<td>
<uc2:TopNavHome ID="TopNavHome1" runat="server" />
<%--TopNavControl--%>
</td>
</tr>
<tr>
<td valign="top">
<table width="100%" border="0" cellpadding="0"
cellspacing="0">
<tr>
<td valign="top" class="LeftNavArea">
<%--SearchControl--%><br />
<%--LeftNavControl--%>
</td>
<td valign="top" class="BodyBox">
<%--PageTitleControl--%>
<span class="Content">
<asp:contentplaceholder
id="BodyContentPlaceHolder" runat="server" />
</span>
</td>
</tr>
</table>
</td>
</tr>
<tr>
<td class="Footer">
<%--FooterControl--%>
</td>
</tr>
</table>
<br />
<uc1:DefaultConsole ID="DefaultConsole1" runat="server" />

</div>

</form>

<!-- The following will allow the WBC to autoposition and "float" -->
<script language="javascript" type="text/javascript">

function PositionAuthoringConsole() {
alert("testme: " + window.document.body.scrollTop);
}
</script>
</body>
</html>
"Ken Cox [Microsoft MVP]" wrote:
Hi Andy,

Could you show us the master page code? When you view the rendered
source,
do you see something different than expected?

Ken

"Andy" <An**@discussions.microsoft.com> wrote in message
news:C6**********************************@microsof t.com...
> Hey all,
> I'm building out my first project using asp.net v2.0 master pages. It
> seems
> that when you use master pages and try to reference
> document.body.scrollTop
> it allways = zero/0. The same code works in a regular .htm file.
>
> Has anyone else seen this?
> Anyone know how to get the body.scrollTop property using masterpages.
> Thanks for any help
> Andy


May 17 '06 #4
The body.scrollTop value should increase relatively as you scroll down the
page. This should be the relative pixel number to the top of the page.
I use it in our old system to position a MCMS authoring toolbox on the page
(so the toolbox menu floats down the page as the user scrolls down the page)

"Ken Cox [Microsoft MVP]" wrote:
Hi Andy,

I tried your code and I get zero for the value of the body. What's the
expected value?

What object are you trying to test?

Ken
"Andy" <An**@discussions.microsoft.com> wrote in message
news:7E**********************************@microsof t.com...
Hi Ken,
Here's my master page code:
Thanks for any help

<%@ Master Language="C#" AutoEventWireup="true"
CodeFile="PublicSite.master.cs" Inherits="PublicSite" %>
<%@ Register Src="UserControls/TopNavHome.ascx" TagName="TopNavHome"
TagPrefix="uc2" %>
<%@ Register TagPrefix="cms"
Namespace="Microsoft.ContentManagement.WebControls "
Assembly="Microsoft.ContentManagement.WebControls, Version=5.0.1200.0,
Culture=neutral, PublicKeyToken=31bf3856ad364e35" %>
<%@ Register Src="Console/DefaultConsole.ascx" TagName="DefaultConsole"
TagPrefix="uc1" %>
<!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 runat="server">
<title></title>
<cms:RobotMetaTag runat="server"></cms:RobotMetaTag>
<meta name="Description" content="" id="MetaDesc" runat="server" />
<meta name="Keywords" content="" id="MetaKey" runat="server" />
<link href="StyleSheets/PublicSite.css" rel="stylesheet"
type="text/css"
/>
</head>
<body onclick="PositionAuthoringConsole();">
<form id="form1" runat="server">
<div id="testdiv">
<table border="0" cellpadding="0" cellspacing="0" width="770"
class="PageBorder">
<tr class="TopNavRow">
<td>
<uc2:TopNavHome ID="TopNavHome1" runat="server" />
<%--TopNavControl--%>
</td>
</tr>
<tr>
<td valign="top">
<table width="100%" border="0" cellpadding="0"
cellspacing="0">
<tr>
<td valign="top" class="LeftNavArea">
<%--SearchControl--%><br />
<%--LeftNavControl--%>
</td>
<td valign="top" class="BodyBox">
<%--PageTitleControl--%>
<span class="Content">
<asp:contentplaceholder
id="BodyContentPlaceHolder" runat="server" />
</span>
</td>
</tr>
</table>
</td>
</tr>
<tr>
<td class="Footer">
<%--FooterControl--%>
</td>
</tr>
</table>
<br />
<uc1:DefaultConsole ID="DefaultConsole1" runat="server" />

</div>

</form>

<!-- The following will allow the WBC to autoposition and "float" -->
<script language="javascript" type="text/javascript">

function PositionAuthoringConsole() {
alert("testme: " + window.document.body.scrollTop);
}
</script>
</body>
</html>
"Ken Cox [Microsoft MVP]" wrote:
Hi Andy,

Could you show us the master page code? When you view the rendered
source,
do you see something different than expected?

Ken

"Andy" <An**@discussions.microsoft.com> wrote in message
news:C6**********************************@microsof t.com...
> Hey all,
> I'm building out my first project using asp.net v2.0 master pages. It
> seems
> that when you use master pages and try to reference
> document.body.scrollTop
> it allways = zero/0. The same code works in a regular .htm file.
>
> Has anyone else seen this?
> Anyone know how to get the body.scrollTop property using masterpages.
> Thanks for any help
> Andy


May 17 '06 #5
Hey Ken,
Here is a simple sample of how scrollTop should increment as you scroll down
the page. This behavior does not seem to work when using master pages from
what I can see (unless I'm missing something)

Using the relative scrollTop position is the only way I can think of to
position a table/box on the page in a fixed location as the user scrolls down
the page.

Thanks again
Andy
<HTML>
<HEAD><TITLE>Test</TITLE>
</HEAD>
<BODY onscroll="alert(window.document.body.scrollTop);">

..<br />.<br />.<br />.<br />.<br />.<br />.<br />.<br />.<br />.<br />.<br />
..<br />.<br />.<br />.<br />.<br />.<br />.<br />.<br />.<br />.<br />.<br />
..<br />.<br />.<br />.<br />.<br />.<br />.<br />.<br />.<br />.<br />.<br />
..<br />.<br />.<br />.<br />.<br />.<br />.<br />.<br />.<br />.<br />.<br />
..<br />.<br />.<br />.<br />.<br />.<br />.<br />.<br />.<br />.<br />.<br />
..<br />.<br />.<br />.<br />.<br />.<br />.<br />.<br />.<br />.<br />.<br />
..<br />.<br />.<br />.<br />.<br />.<br />.<br />.<br />.<br />.<br />.<br />
..<br />.<br />.<br />.<br />.<br />.<br />.<br />.<br />.<br />.<br />.<br />
..<br />.<br />.<br />.<br />.<br />.<br />.<br />.<br />.<br />.<br />.<br />

</BODY>
</HTML>
May 17 '06 #6
Hey again (sorry to spam you)
I Keep making baby steps.
I created another static page based on master page - IE view source.
I think the first line of the code is the problem - not sure why though -
this is a line that the framework/visual studio generates.
Any idea on why line one would effect the returned value of
document.body.scrollTop?
Thanks again
Andy

<!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></head>
<body onclick="alert(window.document.body.scrollTop);">
<form name="aspnetForm" method="post" action="TestMaster.aspx"
id="aspnetForm">

<div>
-<br />-<br />-<br />-<br />-<br />-<br />-<br />-<br />-<br />-<br />-<br />
-<br />-<br />-<br />-<br />-<br />-<br />-<br />-<br />-<br />-<br />-<br />
-<br />-<br />-<br />-<br />-<br />-<br />-<br />-<br />-<br />-<br />-<br />
-<br />-<br />-<br />-<br />-<br />-<br />-<br />-<br />-<br />-<br />-<br />
-<br />-<br />-<br />-<br />-<br />-<br />-<br />-<br />-<br />-<br />-<br />
-<br />-<br />-<br />-<br />-<br />-<br />-<br />-<br />-<br />-<br />-<br />
-<br />-<br />-<br />-<br />-<br />-<br />-<br />-<br />-<br />-<br />-<br />
-<br />-<br />-<br />-<br />-<br />-<br />-<br />-<br />-<br />-<br />-<br />
-<br />-<br />-<br />-<br />-<br />-<br />-<br />-<br />-<br />-<br />-<br />
</div>
</form>
</body>
</html>
May 17 '06 #7
A little more info...
When you create a master page in Visual studio it auto adds the following
line to your master page file:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

This line seems to cause problems when trying to access
document.body.scrollTop. Not sure why - when I remove this line from my
master file I can get an accurate value of scrollTop.

Anyone have any ideas?
Thanks
Andy

"Andy" wrote:
Hey all,
I'm building out my first project using asp.net v2.0 master pages. It seems
that when you use master pages and try to reference document.body.scrollTop
it allways = zero/0. The same code works in a regular .htm file.

Has anyone else seen this?
Anyone know how to get the body.scrollTop property using masterpages.
Thanks for any help
Andy

May 17 '06 #8
check this out.

http://www.vbforums.com/showthread.php?t=386200

SA
"Andy" <An**@discussions.microsoft.com> wrote in message
news:F9**********************************@microsof t.com...
A little more info...
When you create a master page in Visual studio it auto adds the following
line to your master page file:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

This line seems to cause problems when trying to access
document.body.scrollTop. Not sure why - when I remove this line from my
master file I can get an accurate value of scrollTop.

Anyone have any ideas?
Thanks
Andy

"Andy" wrote:
Hey all,
I'm building out my first project using asp.net v2.0 master pages. It
seems
that when you use master pages and try to reference
document.body.scrollTop
it allways = zero/0. The same code works in a regular .htm file.

Has anyone else seen this?
Anyone know how to get the body.scrollTop property using masterpages.
Thanks for any help
Andy

May 17 '06 #9
Wow. That's a new one on me. I guess IE is paying attention to something in
the XHTML specification.

"Andy" <An**@discussions.microsoft.com> wrote in message
news:3B**********************************@microsof t.com...
Hey again (sorry to spam you)
I Keep making baby steps.
I created another static page based on master page - IE view source.
I think the first line of the code is the problem - not sure why though -
this is a line that the framework/visual studio generates.
Any idea on why line one would effect the returned value of
document.body.scrollTop?
Thanks again
Andy

<!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></head>
<body onclick="alert(window.document.body.scrollTop);">
<form name="aspnetForm" method="post" action="TestMaster.aspx"
id="aspnetForm">

<div>
-<br />-<br />-<br />-<br />-<br />-<br />-<br />-<br />-<br />-<br />-<br
/>
-<br />-<br />-<br />-<br />-<br />-<br />-<br />-<br />-<br />-<br />-<br
/>
-<br />-<br />-<br />-<br />-<br />-<br />-<br />-<br />-<br />-<br />-<br
/>
-<br />-<br />-<br />-<br />-<br />-<br />-<br />-<br />-<br />-<br />-<br
/>
-<br />-<br />-<br />-<br />-<br />-<br />-<br />-<br />-<br />-<br />-<br
/>
-<br />-<br />-<br />-<br />-<br />-<br />-<br />-<br />-<br />-<br />-<br
/>
-<br />-<br />-<br />-<br />-<br />-<br />-<br />-<br />-<br />-<br />-<br
/>
-<br />-<br />-<br />-<br />-<br />-<br />-<br />-<br />-<br />-<br />-<br
/>
-<br />-<br />-<br />-<br />-<br />-<br />-<br />-<br />-<br />-<br />-<br
/>
</div>
</form>
</body>
</html>

May 17 '06 #10

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
by: Michael Herman \(Parallelspace\) | last post by:
1. What are some compelling solutions for using Master/Content pages with Web Pages? 2. If a content area has a web part zone with web parts, what is the user experience like when "editting" the...
20
by: Alan Silver | last post by:
Hello, In classic ASP, I used to use two include files on each page, one before and one after the main content, to provide a consistent layout across a web site. That way I could just change the...
1
by: Alan Silver | last post by:
Hello, I am just experimenting with master pages, and am trying to add a content placeholder in the <head> section, so that individual pages can set their own page title and meta tags. The...
0
by: gregtyndall | last post by:
I have a weird problem. I'm using a master page to hold a menu that I want to scroll as the user scrolls in the browser window so it will always be visible. First off, putting onsroll in the body...
17
by: Rob R. Ainscough | last post by:
Again another simple concept that appears NOT to be intuitive or I'm just stupid. I've read the WROX book and the example doesn't actually show how the .master page links in the other content...
0
by: bluegrasslover | last post by:
I've gotten a couple of emails about this problem lately so I'm going to post the solution that someone emailed me a while back. When you create a master page visual studio automatically adds a...
1
by: Luminari | last post by:
I have two pages. Both of them are supposed to have one table on it with a fixed header. Both pages were tested in IE6. Structurally they are identical. Both have a <divthat wraps a <tablethat...
3
by: Rich | last post by:
Hi, I want to use 2 master pages, one for the main part of the site, the other for the admin pages. They are quite similar, with many shared elements. Ideally I would like to have a parent...
0
by: MeoLessi9 | last post by:
I have VirtualBox installed on Windows 11 and now I would like to install Kali on a virtual machine. However, on the official website, I see two options: "Installer images" and "Virtual machines"....
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: Aftab Ahmad | last post by:
Hello Experts! I have written a code in MS Access for a cmd called "WhatsApp Message" to open WhatsApp using that very code but the problem is that it gives a popup message everytime I clicked on...
0
by: Aftab Ahmad | last post by:
So, I have written a code for a cmd called "Send WhatsApp Message" to open and send WhatsApp messaage. The code is given below. Dim IE As Object Set IE =...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: marcoviolo | last post by:
Dear all, I would like to implement on my worksheet an vlookup dynamic , that consider a change of pivot excel via win32com, from an external excel (without open it) and save the new file into a...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.