Results 1 to 3 of 3
  1. #1
    Lounger
    Join Date
    May 2002
    Location
    Fort Worth, Texas, USA
    Posts
    36
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Create Controls at Runtime (VB.net 2002)

    In VB 6 it was a no brainer to create new controls at runtime, how do I do this with VB.net to create an ASP.net page? <img src=/S/confused.gif border=0 alt=confused width=15 height=20>

  2. #2
    Silver Lounger
    Join Date
    Jan 2001
    Location
    Indianapolis, Indiana, USA
    Posts
    1,862
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Create Controls at Runtime (VB.net 2002)

    After creating the controls, you have to add them to a collection (either Page, Panel, or PlaceHolder objects).

    Dim lbl as new System.Web.UI.WebControls.Label
    With lbl
    .ID = "lblTest"
    .Text = "My New Label"
    End With
    Me.Controls.Add(lbl)

    Check out a great reference (VB and C#) here: http://www.dotnetforums.net/t78075.html

  3. #3
    Lounger
    Join Date
    May 2002
    Location
    Fort Worth, Texas, USA
    Posts
    36
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Create Controls at Runtime (VB.net 2002)

    That worked perfectly! I dimmed the control as an array added a for/next loop and I am set.
    <img src=/S/thankyou.gif border=0 alt=thankyou width=40 height=15>

Posting Permissions

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