Problem: adding textbox during runtime (VB.NET) webforms

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • ton

    Problem: adding textbox during runtime (VB.NET) webforms

    Hi,

    I want to add several textbox to my form during runtime: the code is very
    simple

    Lab = New TextBox
    Lab.ID = "A" & i
    Lab.Height = 200
    Lab.Visible = True
    Lab.Text = "test"
    Lab.Attributes. Add("runat", "Server")
    Lab.Attributes( "style") = " LEFT: " & x & "px; POSITION:
    absolute; TOP:" & 250 * i & "px "
    Controls.Add(La b)

    after this I receive an error which tells me that the textbox should be
    placed within a form label with runat=server.
    Adding a label works fine

    thanks


    ton





  • ton

    #2
    Re: Problem: adding textbox during runtime (VB.NET) webforms

    solved. I've changed the code to:
    Page.FindContro l("form1").Cont rols.Add(Lab) the runat attributes is not
    necessary

    But I have another problem, the textbox is displayed behind a table. I want
    to have it on top of the table.


    Who can help me


    Thanks

    ton

    "ton" <ton@nospam.nls chreef in bericht
    news:511a1$47be a7bd$541eee8e$3 441@cache4.tilb u1.nb.home.nl.. .
    Hi,
    >
    I want to add several textbox to my form during runtime: the code is very
    simple
    >
    Lab = New TextBox
    Lab.ID = "A" & i
    Lab.Height = 200
    Lab.Visible = True
    Lab.Text = "test"
    Lab.Attributes. Add("runat", "Server")
    Lab.Attributes( "style") = " LEFT: " & x & "px; POSITION:
    absolute; TOP:" & 250 * i & "px "
    Controls.Add(La b)
    >
    after this I receive an error which tells me that the textbox should be
    placed within a form label with runat=server.
    Adding a label works fine
    >
    thanks
    >
    >
    ton
    >
    >
    >
    >
    >

    Comment

    Working...