Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > Reading values of anonymous controls

Reply
Thread Tools

Reading values of anonymous controls

 
 
KasperBirch@gmail.com
Guest
Posts: n/a
 
      03-29-2006
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

 
Reply With Quote
 
 
 
 
Karl Seguin [MVP]
Guest
Posts: n/a
 
      03-29-2006
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/


<(E-Mail Removed)> wrote in message
news:(E-Mail Removed) 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
>



 
Reply With Quote
 
 
 
Reply

Thread Tools

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 On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Is this a local anonymous class or a member anonymous class Reporter Java 3 05-12-2007 05:23 AM
help with an anonymous array of anonymous hashes noeldamonmiller@gmail.com Perl Misc 1 02-10-2005 01:08 AM
Reading Values of Datagrid Controls DaDev ASP .Net Datagrid Control 0 06-24-2004 08:52 AM
Reading values from multiple "similar" controls Bijoy Naick ASP .Net 1 05-04-2004 07:32 PM
reading values between custom controls MaverickAmit ASP .Net Web Controls 1 10-02-2003 07:52 AM



Advertisments