Please help .... Loop through content page controls

P

pargat.singh

Hi :

I am using Master/Child page in VS2005 and i wrote generic function
to show/hide controls which works fine if i don't use master/child
[menas it work fine in single page].Below is my function which work
fine for single page to show/hide controls.

private void displayOrHideControls(string ctrlNames, string Mode)
{
string[] arControlNames = ctrlNames.Split(new char[] { ';' });
for (int i = 0; i < arControlNames.Length; i++)
{

string name = arControlNames.ToString();
foreach (Control ctrl in Page.Controls)
{
if (ctrl.HasControls())
{
foreach (Control ctrl2 in ctrl.Controls)
{
if (ctrl2.ID == name)
{
if (Mode == "SHOW")
{
ctrl2.Visible = true;
}
else if (Mode == "HIDE")
{
ctrl2.Visible = false;
}
}
}
}
}
}
}

Can anyone please tell me how can i loop through content page controls?

Thanks,
Pargat
 

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,969
Messages
2,570,161
Members
46,708
Latest member
SherleneF1

Latest Threads

Top