I thought this would not be difficult, but i'm stumped!
I need to iterate through a bunch of form fields, and
read the data (value, text, etc.) from them.
(I need to iterate through them programmaticall y because
it is not known ahead of time which form fields will be
displayed on the browser. The fields will be displayed
or hidden depending on what the user just clicked.)
So, on my page, i surrounded my .NET form field controls
inside an <asp:panel id="Pnl_Contain er" runat="server">
control. The reasoning is that i could then access the
collection of controls inside of it.
Sub Button_Onclick( obj as Object, e as EventArgs)
dim i as int32
for i = 0 to Pnl_Container.C ontrols.count - 1
Response.Write( Pnl_Container.C ontrols.Item(i) .id
& "<br>")
Next
End Sub
I can successfully write out the "id" of each 1st level
control. But if a control is a text box, how do I write
out the text inside of it? Or if it is a radio button,
how do i get the "value"? I'm stumped. Please help! :)
Thanks,
John 4 1692
At the risk of getting shot by my fellow helpers, have you considered simply
looping through the form collection?
for each key as string in Request.Form.Ke ys
dim value as string = Request.Form[key]
next
problem is that Key will be the ClientId...but you can deal with that.
Alternatively, you'll need to recurse all children of your panel...
Karl
--
MY ASP.Net tutorials http://www.openmymind.net/
"John Buchmann" <an*******@disc ussions.microso ft.com> wrote in message
news:12******** *************** *****@phx.gbl.. . I thought this would not be difficult, but i'm stumped!
I need to iterate through a bunch of form fields, and read the data (value, text, etc.) from them.
(I need to iterate through them programmaticall y because it is not known ahead of time which form fields will be displayed on the browser. The fields will be displayed or hidden depending on what the user just clicked.)
So, on my page, i surrounded my .NET form field controls inside an <asp:panel id="Pnl_Contain er" runat="server"> control. The reasoning is that i could then access the collection of controls inside of it.
Sub Button_Onclick( obj as Object, e as EventArgs) dim i as int32 for i = 0 to Pnl_Container.C ontrols.count - 1 Response.Write( Pnl_Container.C ontrols.Item(i) .id & "<br>") Next End Sub
I can successfully write out the "id" of each 1st level control. But if a control is a text box, how do I write out the text inside of it? Or if it is a radio button, how do i get the "value"? I'm stumped. Please help! :)
Thanks, John
you need to check the type of the control, and use a cast to access the
properties you want. you could use vb late binding if performance isn't an
issue.
-- bruce (sqlwork.com)
"John Buchmann" <an*******@disc ussions.microso ft.com> wrote in message
news:12******** *************** *****@phx.gbl.. .
| I thought this would not be difficult, but i'm stumped!
|
| I need to iterate through a bunch of form fields, and
| read the data (value, text, etc.) from them.
|
| (I need to iterate through them programmaticall y because
| it is not known ahead of time which form fields will be
| displayed on the browser. The fields will be displayed
| or hidden depending on what the user just clicked.)
|
| So, on my page, i surrounded my .NET form field controls
| inside an <asp:panel id="Pnl_Contain er" runat="server">
| control. The reasoning is that i could then access the
| collection of controls inside of it.
|
| Sub Button_Onclick( obj as Object, e as EventArgs)
| dim i as int32
| for i = 0 to Pnl_Container.C ontrols.count - 1
| Response.Write( Pnl_Container.C ontrols.Item(i) .id
| & "<br>")
| Next
| End Sub
|
| I can successfully write out the "id" of each 1st level
| control. But if a control is a text box, how do I write
| out the text inside of it? Or if it is a radio button,
| how do i get the "value"? I'm stumped. Please help! :)
|
| Thanks,
| John
|
Check out this article, http://www.extremeexperts.com/Net/ar...hControls.aspx
--
Saravana http://dotnetjunkies.com/WebLog/saravana/ www.ExtremeExperts.com
"John Buchmann" <an*******@disc ussions.microso ft.com> wrote in message
news:12******** *************** *****@phx.gbl.. . I thought this would not be difficult, but i'm stumped!
I need to iterate through a bunch of form fields, and read the data (value, text, etc.) from them.
(I need to iterate through them programmaticall y because it is not known ahead of time which form fields will be displayed on the browser. The fields will be displayed or hidden depending on what the user just clicked.)
So, on my page, i surrounded my .NET form field controls inside an <asp:panel id="Pnl_Contain er" runat="server"> control. The reasoning is that i could then access the collection of controls inside of it.
Sub Button_Onclick( obj as Object, e as EventArgs) dim i as int32 for i = 0 to Pnl_Container.C ontrols.count - 1 Response.Write( Pnl_Container.C ontrols.Item(i) .id & "<br>") Next End Sub
I can successfully write out the "id" of each 1st level control. But if a control is a text box, how do I write out the text inside of it? Or if it is a radio button, how do i get the "value"? I'm stumped. Please help! :)
Thanks, John
Thanks for the help everyone. I finally got my problem
fixed. The article on looping through the controls
helped alot!
John This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Adam Parkin |
last post by:
Hi all, what I want to do is write a function to toggle the enabled field of
all controls within a frame, but what I can't figure out is how does one
iterate through all controls in a frame object?
For example, if I wanted to iterate through all controls in a form, I'd
write something like:
Dim x
For Each x In frmMyForm.Controls
x.Enabled = Not x.Enabled
|
by: Paxton |
last post by:
At the risk of being told "If it ain't broke, don't fix it", my code works,
but is ugly.
Part of the admin site I'm working on at the moment includes a facility for
users to enter Formulations (recipes for making cosmetics etc) in 3 stages:
Stage 1: basic info such as title, method etc and number of Phases (steps in
recipe).
Stage 2: dynamically generated form containing the exact number of phases as
textboxes, depending on the number...
|
by: Dave Hansen |
last post by:
OK, first, I don't often have the time to read this group, so
apologies if this is a FAQ, though I couldn't find anything at
python.org.
Second, this isn't my code. I wouldn't do this. But a colleague did,
got an unexpected result, and asked me why. I think I can infer what
is occurring, and I was able to find a simple work-around. But I
thought I'd ask about it anyway.
I've been pushing Python at work for use as a scripting...
|
by: Gustaf Liljegren |
last post by:
I ran into this problem today: I got an array with Account objects. I need
to iterate through this array to supplement the accounts in the array with
more data. But the compiler complains when I try to modify the objects in
the array while iterating through it. I marked the bugs in this code:
// Loop through all previously added accounts
foreach(Account a in a1) // a1 is an ArrayList
{
// If name and context is the same
if(a.Name ==...
|
by: Milsnips |
last post by:
hi there,
i have a strange problem. I want to programatically loop through each
control on a page, but am having issues.
my test example:
1. header.ascx - the ascx control finds all the child controls no problems
2. default.aspx - i dont find any controls that are placed directly on the
| |
by: steph |
last post by:
Hi,
I'm a bit of an access-dummy, and i suppose this problem of mine has a
rather simple solution, but nevertheless i'm not sure i see it at the
moment.
I've got an access-form in datasheet-view and i want to iterate over
it's records and set some values according to our business logic. This
action should be triggered by the user via a button. I suppose i need
to access the record-set the form is based on doing something like:
|
by: krbyxtrm |
last post by:
hello i have this profile for iterating empty vectors:
+0.3us (microsecond) on intel pentium 2.4Ghz
can this added delay to my application be reduced?
i mean near zero delay, its very important.
BTW,
does anyone has another profile for this?
thanks.
|
by: David Veeneman |
last post by:
Is there a way to iterate the components on a form?
I need to determine whether an instance of my custom component (a
System.ComponentModel component) is present in a form. I have tried
iterating the Controls collection, but components do not appear to be in
that collection-- I think it's because components inherit from
MarshalByRefObject, rather than Control.
So, how do I find a form's components collection? Thanks in advance.
|
by: RMWChaos |
last post by:
The next episode in the continuing saga of trying to develop a modular, automated DOM create and remove script asks the question, "Where should I put this code?"
Alright, here's the story: with a great deal of help from gits, I've developed a DOM creation and deletion script, which can be used in multiple applications. You simply feed the script a JSON list of any size, and the script will create multiple DOM elements with as many attributes...
|
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
|
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,...
| |
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...
|
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...
|
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...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
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: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |
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...
| |