0

I am trying to move controls, such as gridviews, around on an ASP.net form depending on which button is clicked. I have read previously that using the control.location property can be used to specify new coordinates for the control, but this property doesn't exist. I am using VS2015 Professional.

Is there a certain namespace that needs to be imported to allow this functionality?

Visual Vincent
  • 18,045
  • 5
  • 28
  • 75
MG2016
  • 3
  • 2

2 Answers2

2

ASP.Net Web Forms will just render HTML for the browser. You can set the CSS to the position you desire though:

YourControlInstance.Attributes.Item("style") = "POSITION: absolute; LEFT: 100px; TOP: 100px"
NoAlias
  • 9,218
  • 2
  • 27
  • 46
1

The Location property exists only for Windows Forms controls. ASP.NET doesn't implement such capabilities (or at least not in that simple manner) as the controls' positions are determined by the different attributes and CSS-styles you apply to a control.

If you want to freely move around controls you could either try using CSS or you can apparently use a placeholder control.

Community
  • 1
  • 1
Visual Vincent
  • 18,045
  • 5
  • 28
  • 75