Link to home
Start Free TrialLog in
Avatar of JetForce
JetForce

asked on

passing the position of a div tag to the server

Is there a simple way of getting the position of a div tag passed to the server so I can save it for later use.
I will be allowing the div to positioned using javascript (I will know the id of the div).

I have one idea of how to do it, but I would like a few suggestions to see if it they are along my line of thoughts.

Thanks

Jetforce
Avatar of Bob Learned
Bob Learned
Flag of United States of America image

Does the <div> element have an ID and a runat="server" attribute?

Bob
Avatar of JetForce
JetForce

ASKER

The LearnedOne,
It has indeed.
C# example:

        HtmlContainerControl div = (HtmlContainerControl)this.FindControl("div1");

Bob
OK
 I understand how to get the control, but how do I get its position on the form, ie top, left etc

Thanks
HtmlContainerControl div = (HtmlContainerControl)this.FindControl("div1");
string left = div.Style["LEFT"];
string top = div.Style["TOP"];

Bob
that is fine, but it does not give me the new position where it has been moved to.

"I will be allowing the div to positioned using javascript!"

I only get the original position

Thanks
If you need to pass a value from client-side JavaScript to server-side code-behind, you could use a hidden element.

Bob
exactly what I have done, but I was wondering if there was a more elegant way

thanks
ASKER CERTIFIED SOLUTION
Avatar of Bob Learned
Bob Learned
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Bob,
  thanks for you help,

Jetforce