Improve company productivity with a Business Account.Sign Up

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 510
  • Last Modified:

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
0
JetForce
Asked:
JetForce
  • 5
  • 5
1 Solution
 
Bob LearnedCommented:
Does the <div> element have an ID and a runat="server" attribute?

Bob
0
 
JetForceAuthor Commented:
The LearnedOne,
It has indeed.
0
 
Bob LearnedCommented:
C# example:

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

Bob
0
The 14th Annual Expert Award Winners

The results are in! Meet the top members of our 2017 Expert Awards. Congratulations to all who qualified!

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

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

Bob
0
 
JetForceAuthor Commented:
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
0
 
Bob LearnedCommented:
If you need to pass a value from client-side JavaScript to server-side code-behind, you could use a hidden element.

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

thanks
0
 
Bob LearnedCommented:
If you are looking for a more elegant way, I wouldn't have it.

Bob
0
 
JetForceAuthor Commented:
Bob,
  thanks for you help,

Jetforce
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

  • 5
  • 5
Tackle projects and never again get stuck behind a technical roadblock.
Join Now