Get Help:Ask a Question in our Forums|Report a Bug|More Help Resources
Last post Sep 17, 2007 11:36 AM by Kaan
Apr 17, 2007 08:09 AM|LINK
Ajax Control Toolkit 1.0
I need to get the location coordinates (left,top) of a DragPanelExtender after the drop action.
I can obtain the coordinates of the control, calling the following jscript function, where 'Panel1' is trhe containing control, 'drag1' is the 'BehaviorID' of the DragPanelExtender control.
var rcp = $find('drag1');
var location = rcp.get_location();
$get("coordx").innerHTML = location.x;
$get("coordy").innerHTML = location.y;
Unlukly this method works fine the first time you call it, but does not work at all in answer of the next drop events.
In the late case the location.x and location.y value is undefined.
Can anybody help me?
Apr 17, 2007 06:18 PM|LINK
Apr 18, 2007 08:26 AM|LINK
I thank you very much for the suggestion.
do you know how to hook the PropertyChanged('location') event of the control?
I have tried to insert an handle for almost every function in the source code ( see..\DragPanel\FloatingBehaviour.js) but the only handle that hooks the event after a control displacement is "drop"
Al the other handles works only the first time end next do nothing.
The drop event works fine, but all the get_location() calls after the first one return location.x and location.y is Undefined. So, I think the problem is to understand what is the right function to call to obtain the control location after
a drop (if there is one).
Apr 18, 2007 06:29 PM|LINK
You would hook into that event in this way and expect the event to be raised every time the drag panel is done moving and the location has actually changed.
Apr 19, 2007 09:28 AM|LINK
your code does not work, because the $find method returns the component object that contains the component requested by ID, while the $addHandler method needs a Sys.UI.DomElement as first argument. So, the IE gets the following error:
Sys.ArgumentException: Value must be a DOM Element.
Is it really so difficult to do this stupid job?
Apr 19, 2007 06:34 PM|LINK
I had not tried the code I recommended but since you suggested that it did not work I went ahead and tested it and it seemed to the right thing for me everytime. I am not special casing for just the location property and I could perhaps get rid of the params
in the second function because of that. But here is the code. This code is not perfect but it should give you a general idea.
label.innerHTML = loc;
And here is the html:
Apr 20, 2007 04:07 AM|LINK
Actually I went ahead and fixed the code. I now add the handler to the application load event. Also, I was adding the propertyChanged handler incorrectly.
Here is the fixed code:
Apr 20, 2007 07:40 AM|LINK
I thank you very much.
I think your code will be very useful. I am now out of office till next week. I will try your code as soon as possible.
I will report you about.
Apr 20, 2007 03:30 PM|LINK
Your code works fine!! [:)]
I Thank you very much for your useful suggestions.
Jun 05, 2007 03:06 PM|LINK
Thanks for the code, this is great! I was able to stick the coordinates in a textbox and then have a button call a postback and pickup the coordinates from the textbox and let me set the coordinates in the style for the panel so that it keeps position on
postback. My only issue now is if a user moves the object again, the coordinates are off...they seem to be relative to its new starting location. Is there any way to make it always get coordinates relative to 0,0 of the page?