473,839 Members | 1,374 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Basic dynamic repeating form element in ASP.NET2.0?

Does anyone know how I can do the following sort of thing (written in
classic ASP), but in ASP.NET?

This is a very, very basic repeating form element which uses a counter
'cntItems' to hold the current selected number of repeats:
<% for intCounter = 1 to cntItems %>

<input type="text" name="txtInput< % =intCounter %>">
<br>

<% next %>
This would create a list of textboxes named 'txtInput1' through to
e.g. 'txtInput8' if the value of cntItems happens to be 8. I just
can't seem to find any examples of this being done in .NET, any advice
much appreciated!

Thanks, Mark

Apr 26 '07 #1
2 1554
something along the lines of...

TextBox tb;
for (count = 1; count <= cntItems; count++)
{
tb = new TextBox();
tb.ID = "txtInput" + count.ToString( );
Page.Controls.A dd(tb);
Page.Controls.A dd(new LiteralControl( "<br/>");
}
--
Best regards,
Dave Colliver.
http://www.AshfieldFOCUS.com
~~
http://www.FOCUSPortals.com - Local franchises available

<mj**********@g mail.comwrote in message
news:11******** **************@ r3g2000prh.goog legroups.com...
Does anyone know how I can do the following sort of thing (written in
classic ASP), but in ASP.NET?

This is a very, very basic repeating form element which uses a counter
'cntItems' to hold the current selected number of repeats:
<% for intCounter = 1 to cntItems %>

<input type="text" name="txtInput< % =intCounter %>">
<br>

<% next %>
This would create a list of textboxes named 'txtInput1' through to
e.g. 'txtInput8' if the value of cntItems happens to be 8. I just
can't seem to find any examples of this being done in .NET, any advice
much appreciated!

Thanks, Mark

Apr 26 '07 #2
Many thanks Dave, appreciated.
On 26 Apr, 14:39, "David"
<david.colliver .N...@revilloc. REMOVETHIS.comw rote:
something along the lines of...

TextBox tb;
for (count = 1; count <= cntItems; count++)
{
tb = new TextBox();
tb.ID = "txtInput" + count.ToString( );
Page.Controls.A dd(tb);
Page.Controls.A dd(new LiteralControl( "<br/>");

}

--
Best regards,
Dave Colliver.http://www.AshfieldFOCUS.com
~~http://www.FOCUSPortals.com- Local franchises available

<mj.redfox...@g mail.comwrote in message

news:11******** **************@ r3g2000prh.goog legroups.com...
Does anyone know how I can do the following sort of thing (written in
classic ASP), but inASP.NET?
This is a very, very basicrepeatingf ormelement which uses a counter
'cntItems' to hold the current selected number of repeats:
<% for intCounter = 1 to cntItems %>
<input type="text" name="txtInput< % =intCounter %>">
<br>
<% next %>
This would create a list of textboxes named 'txtInput1' through to
e.g. 'txtInput8' if the value of cntItems happens to be 8. I just
can't seem to find any examples of this being done in .NET, any advice
much appreciated!
Thanks, Mark- Hide quoted text -

- Show quoted text -

Apr 27 '07 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
2235
by: Wolfgang Lipp | last post by:
my question is: do we need container elements for repeating elements in data-centric xml documents? or is it for some reason very advisable to introduce containers in xml documents even where not strictly needed? how can a recommendation on this in the light of existing tools like w3c xml schema and relaxng as well es established practice be answered? i would greatly appreciate any words, pointers, and links. the exposition of the...
3
2209
by: Scott | last post by:
Relative newbie here, I'm looking to display the value of radio buttons and check boxes on the page before submission. So far I can do most of it. When "Hat" is checked there are to be no color options available. Click on shirt or pants, you have three options, (actually four if you chose "None"). Shirts and pants can have multiple colors. OK, here is the issue, if you choose a color then change your mind and then un-check the box, it...
2
1803
by: Dave A | last post by:
I just don't get this... If I need to dynamically load controls into a web page I simply need to go PlaceHolder1.Controls.Add(new Button()); or similar. However when I need to dynamically load a web user control into a web page then if we use the same syntax it will appear to work but the web control will throw all sorts of null reference exceptions. Rather for web user controls you have to use the syntax ...
6
2012
by: lloyduh234 | last post by:
Is there a way to dynamically create user scoped settings? For example, a lookup window inside an MDI application that is called by multiple forms and needs to maintain it's size and position based on the MDI child form from which it was called.
0
9697
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10909
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
10650
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9426
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7830
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
7019
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5682
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5867
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4492
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.