Results 1 to 3 of 3

Thread: Code generation

  1. #1

    Thread Starter
    Frenzied Member
    Join Date
    Jan 2001
    Location
    Denmark
    Posts
    1,049

    Question Code generation

    I wish to generate 100 text fields like this code:
    Code:
    <asp:TextBox id="TextBox1" runat="server"></asp:TextBox>
    <asp:TextBox id="TextBox2" runat="server"></asp:TextBox>
    <asp:TextBox id="TextBox3" runat="server"></asp:TextBox>
    <asp:TextBox id="TextBox4" runat="server"></asp:TextBox>
    <asp:TextBox id="TextBox5" runat="server"></asp:TextBox>
    .
    .
    .
    <asp:TextBox id="TextBox100" runat="server"></asp:TextBox>
    How can I do that without writing the code manually?

  2. #2
    Lively Member
    Join Date
    Jan 2001
    Location
    Worcester, MA
    Posts
    77
    This would work

    Code:
    Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
    if not page.ispostback then
    buildoxes()
    end if
    end sub
    
    Sub buildboxes()
    dim t as textbox=new textbox
    dim i as integer
    for i=0 to 99
    t.id="textbox" & i
    page.controls.add(t)
    next
    end sub
    "Find all you need in your mind if you take the time" -DT

  3. #3

    Thread Starter
    Frenzied Member
    Join Date
    Jan 2001
    Location
    Denmark
    Posts
    1,049
    Great, thanks! But what if I have some HTML code e.g. two tables and the I wish to place the 100 text fields a specific place in my HTML-code?
    [code]
    <html>
    <body>
    <tr>
    <td>This is table one</td>
    <td>This is table one</td>
    </tr>
    <tr>
    <td>This table two</td>
    <td>[here I want the 100 text fields]</td>
    </tr>
    </body>
    </html>

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