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.

See also  Why ChatGPT Is So Important Today
devxblackblue

About Our Editorial Process

At DevX, we’re dedicated to tech entrepreneurship. Our team closely follows industry shifts, new products, AI breakthroughs, technology trends, and funding announcements. Articles undergo thorough editing to ensure accuracy and clarity, reflecting DevX’s style and supporting entrepreneurs in the tech sphere.

See our full editorial policy.

About Our Journalist