18927

Define a Label Asp.net Coordinates through C#

Question:

I need to create dinamically a System.Web.UI.WebControls.Label and define its cordinates in the Asp.net Page.

I know it absolute position (x,y). But i dont know any way to define it. Here is how i create the label:

System.Web.UI.WebControls.Label box3 = new System.Web.UI.WebControls.Label(); box3.Text = entradas.ElementAt(0).text; box3.ID = "box3"; //need to define x and y here

The question is how to define its position. Thanks in advance

Answer1:

The Label control has an <a href="http://msdn.microsoft.com/en-us/library/system.web.ui.webcontrols.webcontrol.attributes.aspx" rel="nofollow">Attributes</a> property which you can use to define the labels position on the front end.

For example: -

label.Attributes.Add("style", "top:10; right:10; position:absolute;");

Alternatively, you could just apply some CSS to the rendered HTML...

Recommend

  • Reset inputs with reactive app in shiny
  • Using a factory as source data in angular-datatables doesn't work
  • Adding a different onclick for each div with one loop [duplicate]
  • .NET Core IHttpContextAccessor issue
  • How do I redirect with a Drop Down List, and not a Button?
  • How to use compare validator to compare the data between two dropdownlists values?
  • Grails/Roo for a .Net developer
  • Is MVC2 ASP.Net URLDecoding automatically?
  • jParallax trouble
  • ASP.NET MVC2 Error: No parameterless constructor defined for this object
  • How do i find all references to a user control
  • Symfony2 redirect to https route fails (uses wrong port)
  • PostgreSQL 9.x - pg_read_binary_file & inserting files into bytea
  • Deduce parent class of inherited method in C++
  • Making header act like google chrome mobile app address bar
  • C# List of Panels
  • Hide HTML elements without javascript, only CSS
  • How to return DataSet (xsd) in WCF
  • Blackberry - Custom EditField Cursor
  • Transactional Create with Validation in ServiceStack Redis Client
  • Custom validator control occupying space even though display set to dynamic
  • Body moving without any force applied? (Box2d)
  • java.lang.NoClassDefFoundError: com.parse.Parse$Configuration$Builder on below Lollipop versions
  • Why HTML5 Canvas with a larger size stretch a drawn line?
  • Get object from AWS S3 as a stream
  • Why doesn't :active or :focus work on text links in webkit? (safari & chrome)
  • Cross-Platform Protobuf Serialization
  • Validaiting emails with Net.Mail MailAddress
  • MySQL WHERE-condition in procedure ignored
  • htaccess rewriting URLs with multiple forward slashes
  • Which linear programming package should I use for high numbers of constraints and “warm starts” [clo
  • Display Images one by one with next and previous functionality
  • Web-crawler for facebook in python
  • Do I've to free mysql result after storing it?
  • VB.net deserialize, JSON Conversion from type 'Dictionary(Of String,Object)' to type '
  • A cron job substitute?
  • json Serialization in asp
  • trying to dynamically update Highchart column chart but series undefined
  • Android Google Maps API OnLocationChanged only called once
  • java string with new operator and a literal