devxlogo

Dynamically moving a server control

Dynamically moving a server control

Dynamically moving a server control instance on the page is very easy, thanks to the possibility to add any style attribute to the control. In this case, you can dynamically add the control’s LEFT and TOP coordinates, and another attribute that says you want to use DHTML’s absolute positioning. To try this, just add a button control on the form, and add the following code in the button’s Click event:

Private Sub Button1_Click(...) Handles Button1.Click    Button1.Style.Add("POSITION", "absolute")    Button1.Style.Add("LEFT", "300px")    Button1.Style.Add("TOP", "200px")End Sub

Run the page and click the button. When the form is reloaded, after the postback, the button will be positioned in the new location.

devx-admin

Share the Post: