Please help .... Loop through content page controls

Discussion in 'ASP .Net' started by pargat.singh@gmail.com, Apr 24, 2006.

  1. Guest

    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
    , Apr 24, 2006
    #1
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. =?Utf-8?B?Q2FsdmluIEtE?=

    Loop through webform controls - please help me

    =?Utf-8?B?Q2FsdmluIEtE?=, Jun 17, 2005, in forum: ASP .Net
    Replies:
    2
    Views:
    3,237
    =?Utf-8?B?Q2FsdmluIEtE?=
    Jun 20, 2005
  2. J.Edwards
    Replies:
    0
    Views:
    1,654
    J.Edwards
    Jan 20, 2006
  3. hazz
    Replies:
    6
    Views:
    49,379
    SkyUCHC
    Jun 9, 2010
  4. KK
    Replies:
    2
    Views:
    510
    Big Brian
    Oct 14, 2003
  5. Isaac Won
    Replies:
    9
    Views:
    348
    Ulrich Eckhardt
    Mar 4, 2013
Loading...

Share This Page