Solved

How do I move a Control Programatically?

Posted on 2006-06-19
7
220 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
Networking for the Cloud Era

Join Microsoft and Riverbed for a discussion and demonstration of enhancements to SteelConnect:
-One-click orchestration and cloud connectivity in Azure environments
-Tight integration of SD-WAN and WAN optimization capabilities
-Scalability and resiliency equal to a data center

 
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: Postgres Monitoring System

A PHP and Perl based system to collect and display usage statistics from PostgreSQL databases.

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

Suggested Solutions

Title # Comments Views Activity
ASP.net 2015 Syncing Azure web app projects on two machines 2 26
ASP.NET MVC identity 6 30
Question about JQuery and asp.net 3 31
Easy filter aspnet 2 27
Just a quick little trick I learned recently.  Now that I'm using jQuery with abandon in my asp.net applications, I have grown tired of the following syntax:      (CODE) I suppose it just offends my sense of decency to put inline VBScript on a…
Problem Hi all,    While many today have fast Internet connection, there are many still who do not, or are connecting through devices with a slower connect, so light web pages and fast load times are still popular.    If your ASP.NET page …
A short tutorial showing how to set up an email signature in Outlook on the Web (previously known as OWA). For free email signatures designs, visit https://www.mail-signatures.com/articles/signature-templates/?sts=6651 If you want to manage em…

821 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