473,395 Members | 1,568 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,395 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 3921
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: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

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.