Variable Name Modifier - Is it Possible ?

  • Thread starter Thread starter mosscliffe
  • Start date Start date
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
 
Bruce

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

or

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


Brilliant many thanks

Richard
 
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.
 
Back
Top