Solved

How do I move a Control Programatically?

Posted on 2006-06-19
7
221 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
PeopleSoft Has Never Been Easier

PeopleSoft Adoption Made Smooth & Simple!

On-The-Job Training Is made Intuitive & Easy With WalkMe's On-Screen Guidance Tool.  Claim Your Free WalkMe Account Now

 
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

Technology Partners: 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!

Question has a verified solution.

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

One of the pain points with developing AJAX, JavaScript, JQuery, and other client-side behaviors is that JavaScript doesn’t allow for cross domain request for pulling content. For example, JavaScript code on www.johnchapman.name could not pull conte…
User art_snob (http://www.experts-exchange.com/M_6114203.html) encountered strange behavior of Android Web browser on his Mobile Web site. It took a while to find the true cause. It happens so, that the Android Web browser (at least up to OS ver. 2.…
The Email Laundry PDF encryption service allows companies to send confidential encrypted  emails to anybody. The PDF document can also contain attachments that are embedded in the encrypted PDF. The password is randomly generated by The Email Laundr…
How to Install VMware Tools in Red Hat Enterprise Linux 6.4 (RHEL 6.4) Step-by-Step Tutorial

740 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