Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Get Calendar Picker's position

Status
Not open for further replies.

Strobeman

Programmer
May 16, 2003
40
AU
One of my colleagues has written a calendar picker function and it is popping up the calendar in the top left of the screen. He has gone on vacation and I have been asked to reposition it beneath the field the date will be displayed in. Can someone please tell me how to get the X and Y coordinates of a field on a web form?

To position it on the cursor I am using the following:

ScriptManager.RegisterClientScriptBlock(this, typeof(controls_DatePicker), ClientID + "_onPickerChange",
string.Format(@"function {2}_onPickerChange(){{
{0}.SetSelectedDate({1}.GetSelectedDate());
{0}.Show(event.clientX, event.clientY);}}", ClientID, Picker.ClientID, Calendar.ClientID), true);

Many thanks
 
utilize offsetHeight, offsetTop and offsetLeft:


Code:
var leftPoint = [i]<YourObject>[/i].offsetLeft;
var topPoint = [i]<YourObject>[/i].offsetTop + [i]<YourObject>[/i].offsetHeight

Then, pass those values in as the X and Y.



*cLFlaVA
----------------------------
[tt]"quote goes here"[/tt]
[URL unfurl="true"]http://www.coryarthus.com/[/url]
 
Thanks for your prompt response cLFlaVA.
Unfortunately I am not able to see those properties.
I am using ASP.Net with C# if that makes a difference.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top