How to refer a object by it's ID

  • Thread starter Thread starter ad
  • Start date Start date
A

ad

I have a string variable
string sID;

sID store the ID of a TextBox.

I want to refer TextBox throw sID. like (TextBox which ID is
sID).Text="text";

How can I do that ?
 
ad said:
I have a string variable
string sID;

sID store the ID of a TextBox.

I want to refer TextBox throw sID. like (TextBox which ID is
sID).Text="text";

How can I do that ?
If you mean name (id applies to web apps) then.

foreach(control ctl in this.controls)
{
if(ctl.name == controlnamevariable)
{
ctl.text = "MyText";
}
}

or something to this effect.
You could also use reflection.

JB
 
Thanks,
How to use reflection?

If you mean name (id applies to web apps) then.

foreach(control ctl in this.controls)
{
if(ctl.name == controlnamevariable)
{
ctl.text = "MyText";
}
}

or something to this effect.
You could also use reflection.

JB
 
hi,

you do not need reflection,
you can use the Control.Name for win or Control.ID for web.

What is what you want to do? and in what platform

cheers,
 
Back
Top