Variable Name Modifier - Is it Possible ?

M

mosscliffe

I have several buttons on a page btn1, btn2, btn3, btn4 ... btnn

I wish to control their visibilty

for x = 1 to btnCount
btn[var x value].visible = false
next x

where the x is used to convert to a number making the variable name
btn1, btn2 etc

I used to be able to do this in shell scripting, but I can not find how
to do it in VB2005.

Any help, especially an example much appreciated
 
M

mosscliffe

Bruce

page.findcontrol("btn" & x.tostring).visible = false

or

page.findcontrol("btn" & x.tostring).visible = true


Brilliant many thanks

Richard
 
?

=?ISO-8859-1?Q?G=F6ran_Andersson?=

As an alternative, you could make an array that contains references to
the buttons. In C#:

Button[] btn = new Button[] { btn1, btn2, bnt3, btn4 ... btnn };

btn[x].visible = false;

Not as flexible as FindControl, but more efficient.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,577
Members
45,054
Latest member
LucyCarper

Latest Threads

Top