473,406 Members | 2,467 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,406 software developers and data experts.

Make a user control floatable?

Hi,

I have a user control which I use on all my pages. The control is situated
on the top of my page (sits on my master page).

For some long pages the user has to scroll back up to the top of the page to
select an option from my user control.

Can I make this user control floatable so that as the user scrolls down the
page the user control moves down also?

Any info appreciated.

Thanks.

May 31 '07 #1
3 2505
Yes,

search for floating div

Put your UC in a div (or the panel), then you basically use DHTML to allow
it to move.

--
Best regards,
Dave Colliver.
http://www.AshfieldFOCUS.com
~~
http://www.FOCUSPortals.com - Local franchises available
"C" <C@discussions.microsoft.comwrote in message
news:3E**********************************@microsof t.com...
Hi,

I have a user control which I use on all my pages. The control is situated
on the top of my page (sits on my master page).

For some long pages the user has to scroll back up to the top of the page
to
select an option from my user control.

Can I make this user control floatable so that as the user scrolls down
the
page the user control moves down also?

Any info appreciated.

Thanks.

May 31 '07 #2
To explain David's answer a bit:

You use CSS absolute positioning to position a div (or "Panel") that is not
nested in any other element or Control, so that in the HTML it is a child of
the document or form (the form has no effect on positioning). This makes its
position relative to the HTML document itself. You can then position it
using a combination of CSS "left", "top", "right" and/or "bottom" styles
absolutely relative to the document.

Your next problem, of course, is that the document is often larger than the
browser window or ViewPort. If so, the element may be positioned outside of
the ViewPort, such as an element that is positioned at the top of the
document, when the document is scrolled down.

This requires the use of JavaScript to solve (JavaScript + HTML = DHTML).
You have to get the position relative to the top of the window. Fortunately,
the HTML DOM element document.documentElement has a "scrollTop" and
"scrollLeft" property, which indicates the distance from the top/left of the
document and the top/left of the window. So, if you want to position your
element at, say, 20 px down from the top of the window, and 20 pixels to the
right of the left edge of the window, you add 20 to
document.documentElement.scrollTop to get the "top" position style and 20 to
document.documentElement.scrollLeft to get the "left" position.

However, you're not done yet. CSS styles are strings which include the
measuring unit. The pixel measuring unit is "px" - so, you use JavaScript to
concatenate the number to the string "px" to get something like "20px".
JavaScript Example:

function setInfoDiv(x, y)
{
var el = document.getElementById("infoDiv");
var xOffset = x + document.documentElement.scrollLeft;
var yOffset = y + document.documentElement.scrollTop;
el.style.left = xOffset + "px";
el.style.top = yOffset + "px";
}

Now you still have one hurdle to jump. What happens when the document is
scrolled, up, down, left or right? You have to use JavaScript to handle the
"scroll" event of the document. for this, you create an event handler
function that takes 1 argument, an event. You can use this to call the
function above. Example (compatible with IE and FireFox):

function handleScroll(e)
{
setInfoDiv(20, 20);
}
document.onscroll = handleScroll;

Here are a couple of resources that may help:

http://www.quirksmode.org/resources.html
http://developer.mozilla.org/en/docs/DOM:element

--
HTH,

Kevin Spencer
Microsoft MVP

Printing Components, Email Components,
FTP Client Classes, Enhanced Data Controls, much more.
DSI PrintManager, Miradyne Component Libraries:
http://www.miradyne.net

"David" <da*****************@revilloc.REMOVETHIS.comwrot e in message
news:OT**************@TK2MSFTNGP05.phx.gbl...
Yes,

search for floating div

Put your UC in a div (or the panel), then you basically use DHTML to allow
it to move.

--
Best regards,
Dave Colliver.
http://www.AshfieldFOCUS.com
~~
http://www.FOCUSPortals.com - Local franchises available
"C" <C@discussions.microsoft.comwrote in message
news:3E**********************************@microsof t.com...
>Hi,

I have a user control which I use on all my pages. The control is
situated
on the top of my page (sits on my master page).

For some long pages the user has to scroll back up to the top of the page
to
select an option from my user control.

Can I make this user control floatable so that as the user scrolls down
the
page the user control moves down also?

Any info appreciated.

Thanks.


May 31 '07 #3
You could just use the free AlwaysVisible control:
http://ajax.asp.net/ajaxtoolkit/Alwa...leControl.aspx

--
I hope this helps,
Steve C. Orr,
MCSD, MVP, CSM, ASPInsider
http://SteveOrr.net
"C" <C@discussions.microsoft.comwrote in message
news:3E**********************************@microsof t.com...
Hi,

I have a user control which I use on all my pages. The control is situated
on the top of my page (sits on my master page).

For some long pages the user has to scroll back up to the top of the page
to
select an option from my user control.

Can I make this user control floatable so that as the user scrolls down
the
page the user control moves down also?

Any info appreciated.

Thanks.
May 31 '07 #4

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

Similar topics

7
by: Chuck | last post by:
I am working in C# 2003. Can anyone tell me how to make a user control transparent. VS help doesn't help. What I want to do is draw on a user control during design time and then place the...
0
by: Mark | last post by:
I'd like to make a public property on a user control so that a person can drag and drop the user control onto their page, and then modify a public property of the user control at design time in the...
2
by: msnews.microsoft.com | last post by:
It appears myButton_OnClick is triggering in my user control AFTER its parent's Page_Load already runs. Is there a way to make the parent Page_Load to run afterwards? I'm changing a session...
1
by: Bennett Haselton | last post by:
Are there any samples of how to create a user control that uses templates, like the <ItemTemplate> and <HeaderTemplate> of the Repeater control? I tried searching for user control samples on the...
6
by: Selden McCabe | last post by:
I have a form with a bunch of image buttons. When the user moves the mouse over a button, I want to do two things: 1. change the Imagebutton's picture, and 2. make another control visible. I'm...
7
by: aviad | last post by:
I am writing a Form application I need it to fit both resolution of 1600*1200 and 800*600 (and any other resolution that might jump in) the application is meant for regular PCs another question...
6
by: Ian Boyd | last post by:
Every time during development we had to make table changes, we use Control Center. Most of the time, Control Center fails. If you try to "undo all", it doesn't, and you end up losing your identity...
15
by: rizwanahmed24 | last post by:
Hello i have made a custom control. i have placed a panel on it. I want this panel to behave just like the normal panel. The problem i was having is that the panel on my custom control doesnt...
5
by: royend | last post by:
Is it possible to hide images from the internet, and only have a image available for users that are logged into the intranet? I am hoping to avoid a database-solution as the number of images will...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
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: 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
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
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,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

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.