Results 1 to 5 of 5

Thread: How to specify the position of a label control ?

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Jan 2001
    Posts
    115

    Cool How to specify the position of a label control ?

    Hi All,

    In my app, i need to dynamically generate several label control . My problem is how to specify the position of those controls.
    For example,

    Dim lblNew As New System.Web.UI.WebControls.Label()

    now, i want the lblNew located on the specified location. How can i do that ?

  2. #2
    Lively Member
    Join Date
    Jan 2001
    Location
    Worcester, MA
    Posts
    77
    Why not put the lable where you want it then set its visible preperty to false then when you need to use it enable it. Just a thought.
    "Find all you need in your mind if you take the time" -DT

  3. #3

    Thread Starter
    Lively Member
    Join Date
    Jan 2001
    Posts
    115
    Cin0s3 , thank you for the reply. But in my application, the number of label controls can't be determined in advance. I understand i could create a large enough set of labels on the interface and then visible them dynamcially. But still, i want to know if there is a way to dynamically create and locate controls based on request.

  4. #4
    C# Aficionado Lord_Rat's Avatar
    Join Date
    Sep 2001
    Location
    Cave
    Posts
    2,497
    lblNew.Attributes.Add("style", "position: absolute; top: 20px; left: 20px")

    Remember that Run-time created components do not persist view state, meaning you will need to recreate them on every post back if you want them to remain on screen.

    You also cannot tie event handlers to run time created controls in ASP.Net. You can in VB.NET, just not ASP.NET
    Need to re-register ASP.NET?
    C:\WINNT\Microsoft.NET\Framework\v#VERSIONNUMBER#\aspnet_regiis -i

    (Edit #VERSIONNUMBER# as needed - do a DIR if you don't know)

  5. #5

    Thread Starter
    Lively Member
    Join Date
    Jan 2001
    Posts
    115
    Thank you so much Lord_Rat. And you also solved my other question about losing the dynamically-created ctrl on post back. Thanks again.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width