Solved

How do I move a Control Programatically?

Posted on 2006-06-19
7
218 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 35 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 35 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
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

In an ASP.NET application, I faced some technical problems. In this article, I list them out and show the solutions that I found.  I hope it will be useful. Problem: After closing a pop-up window, the parent page should be refreshed automaticall…
IntroductionWhile developing web applications, a single page might contain many regions and each region might contain many number of controls with the capability to perform  postback. Many times you might need to perform some action on an ASP.NET po…
This video explains how to create simple products associated to Magento configurable product and offers fast way of their generation with Store Manager for Magento tool.
A short film showing how OnPage and Connectwise integration works.

919 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

Need Help in Real-Time?

Connect with top rated Experts

21 Experts available now in Live!

Get 1:1 Help Now