Solved

How do I move a Control Programatically?

Posted on 2006-06-19
7
217 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
How to improve team productivity

Quip adds documents, spreadsheets, and tasklists to your Slack experience
- Elevate ideas to Quip docs
- Share Quip docs in Slack
- Get notified of changes to your docs
- Available on iOS/Android/Desktop/Web
- Online/Offline

 
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

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

I have developed many web applications with asp & asp.net and to add and use a dropdownlist was always a very simple task, but with the new asp.net, setting the value is a bit tricky and its not similar to the old traditional method. So in this a…
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…
It is a freely distributed piece of software for such tasks as photo retouching, image composition and image authoring. It works on many operating systems, in many languages.
When you create an app prototype with Adobe XD, you can insert system screens -- sharing or Control Center, for example -- with just a few clicks. This video shows you how. You can take the full course on Experts Exchange at http://bit.ly/XDcourse.

747 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

13 Experts available now in Live!

Get 1:1 Help Now