473,804 Members | 3,081 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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.A dd(text);
tr.Cells.Add(ce ll);
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:Textb ox ..." 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 1237
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*********@gm ail.com> wrote in message
news:11******** **************@ j33g2000cwa.goo glegroups.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.A dd(text);
tr.Cells.Add(ce ll);
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:Textb ox ..." 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
1631
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 changed get passed to a stored procedure to update the table. The problem is that when the form is submitted, the text boxes seem to lose their values and contain nothing but empty strings. I have tested the same code from an .aspx page and it...
5
6937
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 TextBox controls render greyed-out, and I can see the values in the TextBox controls....this is what I expected. I submit again, the Panel is enabled during the PostBack. All of the TextBox controls within the Panel are now enabled, however,...
1
2176
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 addHandler to set btnLogin's Command to a sub that will read in the values from userName and userPass then do the authentication. The problem I'm having is that I can't pass two values through btnLogin.commandargument. Even if I could, is it...
4
1295
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 actually got that working fairly well, but, then, in the end, decided that was overkill and that it would perhaps make more sense to start over using a much more simpler communication between pages.
4
15080
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 this program returns. I'm just missing the stepshere. I know that I can set the Shell command to an integer,but this only returns a 0 to me telling me that it executed, notwhat is being returned to the console by that application. Isthere a way to...
5
3736
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. When the user clicks the "Add another email" it will call a client side JavaScript function, add_email, which will dynamically add a new set of controls to the webpage using the innerHTML method. It appears to work perfectly fine in the browser. The...
0
2410
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, which I am). I now want to read the text/values of those controls. I have found out that I can read the values if I wait until Page_Load, but then I have the same questions showing up again (along with the new questions) and I do not want them to....
13
1987
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 the location value back in where I marked ?????????????????????. As it wont accept a string value? Private Sub Save_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Save.Click
2
2171
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 like this: protected void Page_Load(object sender, EventArgs e) { Dictionary<Guid, stringdataHash = ... //db access foreach(KeyValuePair<Guid, stringrow in dataHash) {
0
9705
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
1
10308
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
10073
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
7609
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
6846
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
5513
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
5645
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
3806
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2981
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.