Hide all controls in a panel in ASP.Net

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • DAnDA
    New Member
    • Jun 2007
    • 35

    Hide all controls in a panel in ASP.Net

    Hi

    Simply i want Hide all Textboxes in a Panel ,,, in asp.net

    i can do it by C# :

    foreach (Control ctrl in Panel1.Controls )
    {
    if (ctrl is TextBox)
    {
    ((TextBox)(ctrl )).Visible = false;
    }

    }

    Can anyone tell me how to do in JavaScript?
  • aliasruel
    New Member
    • Sep 2007
    • 73

    #2
    Hi...
    mmmmm try this code...

    //where controlName is defined as Control (as parameter)
    <script language=""JScr ipt"">
    try
    {
    window.focus();
    document.body.f ocus();
    if (document.all(" "" & controlName & """).tagNam e == 'SELECT')
    {
    document.all("" " & controlName & """).selectedIn dex = 0;
    document.all("" " & controlName & """).focus( );
    }
    else
    {
    document.all("" " & controlName & """).select ();
    document.all("" " & controlName & """).focus( );
    }
    }
    catch(e)
    {
    /**/
    }
    </script>



    regards,
    ruel






    Originally posted by DAnDA
    Hi

    Simply i want Hide all Textboxes in a Panel ,,, in asp.net

    i can do it by C# :

    foreach (Control ctrl in Panel1.Controls )
    {
    if (ctrl is TextBox)
    {
    ((TextBox)(ctrl )).Visible = false;
    }

    }

    Can anyone tell me how to do in JavaScript?

    Comment

    Working...