Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > ASP.NET and ASP > ASP.NET 1.0 and 1.1 > ASP.NET 1.0 and 1.1 Basics
Password Reminder
| FAQ | Members List | Search | Today's Posts | Mark Forums Read
ASP.NET 1.0 and 1.1 Basics ASP.NET discussion for users new to coding in ASP.NET 1.0 or 1.1. NOT for the older "classic" ASP 3 or the newer ASP.NET 2.0.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the ASP.NET 1.0 and 1.1 Basics section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old March 7th, 2004, 01:02 PM
Authorized User
Join Date: Feb 2004
Location: Islamabad, , Pakistan.
Posts: 42
Thanks: 0
Thanked 0 Times in 0 Posts
Default Dynamic generation of controls in ASP.NET

I have managed to write a code that could generate textboxes on-the-fly.
The code is given below:
<script language="vb" runat="server">
Sub Page_Load()
Dim num as Integer
Dim counter as Integer

If Request.Form("select")<>"" Then
    For counter = 1 To num
        Message.Text=Message.Text & _
        "<table><tr><td>Name</td><td><input type=text id=txtName></td></tr><tr><td>Email</td><td><input type=text name=txtEmail><td/></tr></table>"

    Next counter

End If
End Sub

        Enter the number of attendances
        <form runat="server">
        <asp:label id="Message" runat="server"/>
            <asp:DropDownList id="select" runat="server">
                <asp:listitem value=1/>
                <asp:listitem value=2/>
                <asp:listitem value=3/>
                <asp:listitem value=4/>
                <asp:listitem value=5/>
                <asp:listitem value=6/>
        <input type="submit" value="Select" id="smt">

Could someone tell me how to get the data from these dynamically created texboxes.

&nbsp;&nbsp;CEO InteliSoft

Maqsood ur Rahman

Maqsood ur Rahman
Life:An Endless Journey towards Perfection
  #2 (permalink)  
Old March 7th, 2004, 01:32 PM
Friend of Wrox
Join Date: Jun 2003
Location: Copenhagen, , Denmark.
Posts: 440
Thanks: 0
Thanked 0 Times in 0 Posts

Well, first of all you have to give them a unique ID, so that you can tell one from the other, e.g. use the counter to append the current ID.

Then you will be able to retrieve the values from a form just as you are used to!

By the way... You might consider doing the text boxes really dynamically; i.e. using the objects Table, HtmlInputText etc. and add the table to the form!

Hope it helps.


  #3 (permalink)  
Old March 8th, 2004, 07:29 PM
planoie's Avatar
Friend of Wrox
Points: 16,481, Level: 55
Points: 16,481, Level: 55 Points: 16,481, Level: 55 Points: 16,481, Level: 55
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
Join Date: Aug 2003
Location: Clifton Park, New York, USA.
Posts: 5,407
Thanks: 0
Thanked 16 Times in 16 Posts


Building dynamic controls the way you are doing it kind of defeats the purpose and power of ASP.NET. As Jacob suggested, you should use ASP.NET server controls. This way you have the power of those controls at your disposal. Otherwise, you are just scripting like you did in ASP. With the right coding you should never have to access the Request.Form() collection.

Work smarter, not harder.

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
Creating Dynamic ASP.NET Server Controls Using XML kwilliams XSLT 0 October 6th, 2006 01:42 PM
Dynamic generation of .Net button in a position sonaldewle General .NET 0 April 3rd, 2006 03:51 AM
Dynamic generation of asp.net server controls shashi1312 Classic ASP XML 1 August 2nd, 2005 04:52 AM
Dynamic ASP button generation Lloyd_Christmas Classic ASP Basics 1 May 17th, 2005 06:50 PM

All times are GMT -4. The time now is 05:45 AM.

Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.