Dynamically move control.

S

Shawn

I am trying to find a way to move a button control to a location where the
mouse is clicked. I got all the code in to find the coordinates and populate
a hidden control with the values, but when I try to move the button on
postback, it moves, but to a specific place on the form everytime. Here is
where I am doing the move...

Protected Sub Page_Init(ByVal sender As Object, ByVal e As System.EventArgs)
Handles Me.Init
btnLoc.Style("Position") = "Absolute"

btnLoc.Style("Top") = "25px"

btnLoc.Style("Left") = "100px"

End Sub

Any ideas???
 
A

Axel Dahmen

Hi Shawn,

are you sure you want to do this on postback? This way the user would need
for the page to be reloaded before the button appears at the new position.
Depending on the user's internet connection this might take a while...

Anyway, if you want to set a server web control's properties on postback,
you must do so in Page_Load(), not Page_Init(), because object properties
are all reset to their initial values *after* Page_Init() if the object's
EnabledViewState property is set to true.

HTH,
Axel Dahmen
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,744
Messages
2,569,483
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top