473,396 Members | 1,774 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Reading values of anonymous controls

Hi NG

Im trying to read the values of a bunch of TextBox'es that I add in a
loop, dynamically. The page has an <asp:Table id="table" ...> control,
and I add rows with textboxes like this (from memory, never mind
syntax):
for (int i = 0; i<10; i++)
{
TableRow tr = new TableRow();
TableCell cell = new TableCell();
Textbox text = new TextBox();
Cell.Controls.Add(text);
tr.Cells.Add(cell);
table.Rows.Add(tr);
}

The page also has a button and when the user press it, I would like to
read the values of the textboxes...

If they were declared like "<asp:Textbox ..." I would read them like
"this.TextBox1.Value", but how do I do it when they are anonymous?

Kind regards
- Kasper

Mar 29 '06 #1
1 1208
Dynamically added controls need to be re-added , on or before page_load for
their values to get re-associated with them.

So you'll need to re-do that for loop.

As an alternative, you could give ur textboxes a unique "name" and simply
use Request.Form

Karl
--
http://www.openmymind.net/
http://www.fuelindustries.com/
<Ka*********@gmail.com> wrote in message
news:11**********************@j33g2000cwa.googlegr oups.com...
Hi NG

Im trying to read the values of a bunch of TextBox'es that I add in a
loop, dynamically. The page has an <asp:Table id="table" ...> control,
and I add rows with textboxes like this (from memory, never mind
syntax):
for (int i = 0; i<10; i++)
{
TableRow tr = new TableRow();
TableCell cell = new TableCell();
Textbox text = new TextBox();
Cell.Controls.Add(text);
tr.Cells.Add(cell);
table.Rows.Add(tr);
}

The page also has a button and when the user press it, I would like to
read the values of the textboxes...

If they were declared like "<asp:Textbox ..." I would read them like
"this.TextBox1.Value", but how do I do it when they are anonymous?

Kind regards
- Kasper

Mar 29 '06 #2

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

Similar topics

1
by: Philip Townsend | last post by:
I have a user control that contains a form with several text boxes. The text boxes get populated from a SQL Server table when the control loads. When the controls posts back, any values that have...
5
by: Robert Phillips | last post by:
I have a Panel control containing a few TextBox controls. The Panel is originally enabled, I enter data into the TextBox controls. When I submit, the Panel is disabled during the PostBack and the...
1
by: Kevin Bell via .NET 247 | last post by:
Hi All! I am trying to create a simple login feature for my webpage dynamically using VB.NET/ASP.NET. There are two textfields, userName and userPass, and a button, btnLogin. I want to use...
4
by: darrel | last post by:
Karl has helped me in the past in regards to communicating between controls and pages: http://www.openmymind.net/communication/index.html#3.1 I ended up going down the interfaces path and...
4
by: Kevin Mansel via .NET 247 | last post by:
Ok, basically this is my problem. I'm building a console app tocall a dos program. So i'm using the Shell command to call theprogram, now depending on what happens, I want to read theoutput that...
5
by: Dennis Fazekas | last post by:
Greetings, I am creating a web form which will all the user to add an unlimited number of email addresses. Basically I have 3 buttons, "Add Another Email", "-" to remove, and a "Save" button....
0
by: Mike Collins | last post by:
I someone can please help, I am about at an end in trying to figure this out. I am adding some dynamic controls to my page (I found out that I was supposed to be doing that in the oninit event,...
13
by: Marc | last post by:
The first part of the below writes the name and location of all buttons on a from to a text file. The second part reads that information back in and recreates the buttons. My problem is reading...
2
by: Gabe Moothart | last post by:
Hello, In one of my asp.net applications, I create a series of checkboxes, set their properties, and give them an "onChecked" event handler on the fly using an anonymous method. The code looks...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
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,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
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,...

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.