Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

How do I move a Control Programatically?

Posted on 2006-06-19
7
Medium Priority
?
226 Views
Last Modified: 2008-03-04
Hi

I have a label control on a form. When I click on a button on the form I want the label to move to a new position. How do you do this? thx
0
Comment
Question by:rangers99
  • 3
  • 3
7 Comments
 
LVL 9

Assisted Solution

by:tolgaong
tolgaong earned 105 total points
ID: 16934325
you should you clientSide script.

<script>
 function MoveObject()
{
document.getElementById("<%=button1.ClientID %>").style.left = "10px";
}
</script>


to call this you may use: -in the load event-
Button1.Attributes.Add("onclick", "MoveObject()"))
0
 

Author Comment

by:rangers99
ID: 16934371
thx
0
 
LVL 20

Accepted Solution

by:
REA_ANDREW earned 105 total points
ID: 16934444
Points about this, when you say you want to move it to a physically new position; you need to take into account three factors for the client side moving.

1. You need to set its poisition style to absolute;
2. Provide a Top Value
3. Provide a Left Value

So to expand on tolgaong post, you would have this

<script>
 function MoveObject()
{
document.getElementById("<%=button1.ClientID %>").style.position = "absolute";
document.getElementById("<%=button1.ClientID %>").style.left = "10px";
document.getElementById("<%=button1.ClientID %>").style.top = "10px";
}
</script>

For future reference, if would wanted to add animation to this transition, read up about the setTimeout() method in Javascript.

Andrew
:-)
0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 20

Expert Comment

by:REA_ANDREW
ID: 16940170
Can I ask why the grade B?

If we did not fully answer your question in your eyes, why did you not keep it open and continue to ask further questions?

??
0
 

Author Comment

by:rangers99
ID: 16940300
Well I didnt do it to annoy you!

Its just out of habit I think. Like I never give a movie a perfect ten or a meal at a restaurant a perfect 5. If you had come round to my house and actually typed in the code and got the damn thing to work OK Id have given you the top grade.

Im actually not all that sure the correct protocol to follow here and how important the gradings are. I thought it was points that were all important. However in light of your comment Ill review my gradings in future. cheers!
0
 
LVL 20

Expert Comment

by:REA_ANDREW
ID: 16940348
well think if it like this.

it doesn't matter if YOU think the question is difficult or not, it is still the fact that you obviously do not know the answer, hence the reason you post a question on Experts Exchange. So follow this.

1. If you receive a solution and it does what you ask, how more correct can you get - Grade A

2. If you have asked a question and someone, leads you down the path but, does not really answer your question completely - Grade B

3. Same as 2, except they do not make the effort to help your further, after leading you down the path.

Andrew
0
 

Author Comment

by:rangers99
ID: 16941848
Incidentally Ive just tried out the code as described above (should have done it first) and my label control doesnt move. I think its trying to move (it blinks when I click the button) but the son of a bitch aint moving.
0

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.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article discusses the ASP.NET AJAX ModalPopupExtender control. In this article we will show how to use the ModalPopupExtender control, how to display/show/call the ASP.NET AJAX ModalPopupExtender control from javascript, how to show/display/cal…
It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
This course is ideal for IT System Administrators working with VMware vSphere and its associated products in their company infrastructure. This course teaches you how to install and maintain this virtualization technology to store data, prevent vuln…
This lesson discusses how to use a Mainform + Subforms in Microsoft Access to find and enter data for payments on orders. The sample data comes from a custom shop that builds and sells movable storage structures that are delivered to your property. …

963 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question