Hi everyone,
I've run into another road block that google.com isn't able to solve
since I don't even know where to start when searching.
In my webapp, a certain number of table rows containing textboxes is
displayed depending on a number chosen by the user. For example, if
the user chooses 3, there will be three rows displayed with 4 texts
boxes in each row. Using a for loop to create the textboxs, I've
appended a number to the ID of each of the textbox. so Length1,
Width1, Height1, Length2, Width2, Height2 etc...
This is all fine and dandy, but I can't figure out how to reference
these textboxes (to get the information of them and into a struct
stored in a session variable). I recall in ASP that there was some
function which allowed you to evaluate a string and have it behave as
though you entered a proper variable name. For example, I'm looking
for something to convert "Length" + counter.ToStrin g() into something
the compiler will process as a variable. (so the compiler only sees
Length1, Length2 etc... (seeing it as a proper variable name, not as
string).
Any help would be appreciated.
Thanks,
Nicholas 6 2614
<en****@gmail.c om> wrote: I've run into another road block that google.com isn't able to solve since I don't even know where to start when searching.
In my webapp, a certain number of table rows containing textboxes is displayed depending on a number chosen by the user. For example, if the user chooses 3, there will be three rows displayed with 4 texts boxes in each row. Using a for loop to create the textboxs, I've appended a number to the ID of each of the textbox. so Length1, Width1, Height1, Length2, Width2, Height2 etc...
This is all fine and dandy, but I can't figure out how to reference these textboxes (to get the information of them and into a struct stored in a session variable). I recall in ASP that there was some function which allowed you to evaluate a string and have it behave as though you entered a proper variable name. For example, I'm looking for something to convert "Length" + counter.ToStrin g() into something the compiler will process as a variable. (so the compiler only sees Length1, Length2 etc... (seeing it as a proper variable name, not as string).
Instead of using different variables for each textbox, why not just
have an array of them?
--
Jon Skeet - <sk***@pobox.co m> http://www.pobox.com/~skeet Blog: http://www.msmvps.com/jon.skeet
If replying to the group, please do not mail me too
There isn't much need for that. The method he is looking for is the
FindControl method on the Page class, which will find the control based on
the control's identifier.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard. caspershouse.co m
"Jon Skeet [C# MVP]" <sk***@pobox.co m> wrote in message
news:MP******** *************** *@msnews.micros oft.com... <en****@gmail.c om> wrote: I've run into another road block that google.com isn't able to solve since I don't even know where to start when searching.
In my webapp, a certain number of table rows containing textboxes is displayed depending on a number chosen by the user. For example, if the user chooses 3, there will be three rows displayed with 4 texts boxes in each row. Using a for loop to create the textboxs, I've appended a number to the ID of each of the textbox. so Length1, Width1, Height1, Length2, Width2, Height2 etc...
This is all fine and dandy, but I can't figure out how to reference these textboxes (to get the information of them and into a struct stored in a session variable). I recall in ASP that there was some function which allowed you to evaluate a string and have it behave as though you entered a proper variable name. For example, I'm looking for something to convert "Length" + counter.ToStrin g() into something the compiler will process as a variable. (so the compiler only sees Length1, Length2 etc... (seeing it as a proper variable name, not as string).
Instead of using different variables for each textbox, why not just have an array of them?
-- Jon Skeet - <sk***@pobox.co m> http://www.pobox.com/~skeet Blog: http://www.msmvps.com/jon.skeet If replying to the group, please do not mail me too
Nicholas Paldino [.NET/C# MVP] <mv*@spam.guard .caspershouse.c om> wrote: There isn't much need for that. The method he is looking for is the FindControl method on the Page class, which will find the control based on the control's identifier.
You can certainly do that - but I'd argue that using an array is a more
elegant solution than having multiple variables.
--
Jon Skeet - <sk***@pobox.co m> http://www.pobox.com/~skeet Blog: http://www.msmvps.com/jon.skeet
If replying to the group, please do not mail me too
I agree, but with FindControl, you don't need to have any variables at
all, not even the one variable for the array.
When you add a control to ASP, it assigns an id to it (which is the same
name as the reference in the code-behind). You just have to pass this id to
the FindControl method to get the reference to it. In this case, I think it
would be better, since the OP would not have to take the controls and manage
them by placing them in the array. He just has to name them appropriately.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard. caspershouse.co m
"Jon Skeet [C# MVP]" <sk***@pobox.co m> wrote in message
news:MP******** *************** *@msnews.micros oft.com... Nicholas Paldino [.NET/C# MVP] <mv*@spam.guard .caspershouse.c om> wrote: There isn't much need for that. The method he is looking for is the FindControl method on the Page class, which will find the control based on the control's identifier.
You can certainly do that - but I'd argue that using an array is a more elegant solution than having multiple variables.
-- Jon Skeet - <sk***@pobox.co m> http://www.pobox.com/~skeet Blog: http://www.msmvps.com/jon.skeet If replying to the group, please do not mail me too
Nicholas Paldino [.NET/C# MVP] <mv*@spam.guard .caspershouse.c om> wrote: I agree, but with FindControl, you don't need to have any variables at all, not even the one variable for the array.
When you add a control to ASP, it assigns an id to it (which is the same name as the reference in the code-behind). You just have to pass this id to the FindControl method to get the reference to it. In this case, I think it would be better, since the OP would not have to take the controls and manage them by placing them in the array. He just has to name them appropriately.
What exactly do you mean by "the same name as the reference in the
code-behind"? It sounds like you mean the name of a variable...
I don't know how exactly it would all work in ASP.NET, but certainly in
Windows Forms (where I dislike using the designer anyway) an array
would make more sense to me than separate named variables.
--
Jon Skeet - <sk***@pobox.co m> http://www.pobox.com/~skeet Blog: http://www.msmvps.com/jon.skeet
If replying to the group, please do not mail me too
Thanks for all the assistance, everyone has been very helpful.
Nicholas
Jon wrote: Nicholas Paldino [.NET/C# MVP] <mv*@spam.guard .caspershouse.c om> wrote: I agree, but with FindControl, you don't need to have any variables at all, not even the one variable for the array.
When you add a control to ASP, it assigns an id to it (which is the same name as the reference in the code-behind). You just have to pass this id to the FindControl method to get the reference to it. In this case, I think it would be better, since the OP would not have to take the controls and manage them by placing them in the array. He just has to name them appropriately.
What exactly do you mean by "the same name as the reference in the code-behind"? It sounds like you mean the name of a variable...
I don't know how exactly it would all work in ASP.NET, but certainly in Windows Forms (where I dislike using the designer anyway) an array would make more sense to me than separate named variables.
-- Jon Skeet - <sk***@pobox.co m> http://www.pobox.com/~skeet Blog: http://www.msmvps.com/jon.skeet If replying to the group, please do not mail me too This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Kevin Rollo |
last post by:
I'm playing with a generic routine to export data, the concept is to have a
list of data driven templates defining what fields to output.
Evaluating a simple variable field name in the function is easily achieved
by something like
dim rst as dao.recordset
....
strField = "Amount"
debug.print rst.fields(strField) ' or just rst(strField)
|
by: Raed Sawalha |
last post by:
i have the following case
a MyClass class has
method with 2 arguments as
void SetProp(string varname,string varvalue);
in MyClass i have following members
string stdname,stddate,stdbirth,stdloc
from other class i created object from MyClass ,
|
by: markoniinimaki |
last post by:
Hi,
suppose I get a document name a.xml and a path //foo/bar (which nodes
eventually to read from it) from another doc.
Problem: how to combine them so that the whole expression gets
evaluated. I've tried:
<xsl:variable name="imported" select="concat(document('$doc'),$path)"
/>
|
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...
|
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,...
| |
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: 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.
| |