467,077 Members | 974 Online
Bytes | Developer Community
Ask Question

Home New Posts Topics Members FAQ

Post your question to a community of 467,077 developers. It's quick & easy.

HOWTO: Get Web Control Screen Coordinates

How do you get the x,y pixel location of a textbox so that you can position
the Web Date Control popup nearby the associated textbox that will contain
the date selected by the Web Date Control?

--
Thank you kindly,
Dan Sikorsky BAB, BScE, MSC
Nov 18 '05 #1
  • viewed: 4302
Share:
2 Replies
the following client functions work in most browsers:
findPosY = function(obj){
var curtop = 0;
if (document.getElementById || document.all) {
while (obj.offsetParent) {
curtop += obj.offsetTop;
if (typeof(obj.scrollTop) == 'number')
curtop -= obj.scrollTop;
obj = obj.offsetParent;
}
}
else if (document.layers)
curtop += obj.y;
return curtop;
}

findPosX = function(obj) {
var curleft = 0;
if (document.getElementById || document.all) {
while (obj.offsetParent) {
curleft += obj.offsetLeft
obj = obj.offsetParent;
}
}
else if (document.layers)
curleft += obj.x;
return curleft;
}
-- bruse (sqlwork.com)
"Dan Sikorsky" <ds****@gte.net> wrote in message
news:e$**************@TK2MSFTNGP15.phx.gbl...
| How do you get the x,y pixel location of a textbox so that you can
position
| the Web Date Control popup nearby the associated textbox that will contain
| the date selected by the Web Date Control?
|
| --
| Thank you kindly,
| Dan Sikorsky BAB, BScE, MSC
|
|
Nov 18 '05 #2
JavaScript just won't do.

The .NET way should be to handle the button click event on the PostBack and
get the screen coordinates of the button. Then add reasonable offsets to the
x,y point and use that as the position to set the popup position.

Having the calendar on a panel, we need to:

pnlCalendar.Style.Item("top") = iTop

pnlCalendar.Style.Item("left") = iLeft

where iTop and iLeft are the aforementioned screen coordinates (needing to
be appropriately computed ... which is the purpose of this posting).

"bruce barker" <no***********@safeco.com> wrote in message
news:OR**************@tk2msftngp13.phx.gbl...
the following client functions work in most browsers:
findPosY = function(obj){
var curtop = 0;
if (document.getElementById || document.all) {
while (obj.offsetParent) {
curtop += obj.offsetTop;
if (typeof(obj.scrollTop) == 'number')
curtop -= obj.scrollTop;
obj = obj.offsetParent;
}
}
else if (document.layers)
curtop += obj.y;
return curtop;
}

findPosX = function(obj) {
var curleft = 0;
if (document.getElementById || document.all) {
while (obj.offsetParent) {
curleft += obj.offsetLeft
obj = obj.offsetParent;
}
}
else if (document.layers)
curleft += obj.x;
return curleft;
}
-- bruse (sqlwork.com)
"Dan Sikorsky" <ds****@gte.net> wrote in message
news:e$**************@TK2MSFTNGP15.phx.gbl...
| How do you get the x,y pixel location of a textbox so that you can
position
| the Web Date Control popup nearby the associated textbox that will contain | the date selected by the Web Date Control?
|
| --
| Thank you kindly,
| Dan Sikorsky BAB, BScE, MSC
|
|

Nov 18 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

2 posts views Thread by Robin Senior | last post: by
1 post views Thread by Tantra Veda | last post: by
3 posts views Thread by ZorpiedoMan | last post: by
1 post views Thread by zoneal@yahoo.com | last post: by
5 posts views Thread by Jon Slaughter | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.