.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
Sign In
Win Surprise Gifts!!!

Home >> Forum >> ASP.Net >> Post New QuestionBookmark and Share Subscribe to Forum

How to find the controls recursively in a Control

Posted By: Sajid P K     Posted Date: October 12, 2010    Points:2   Category :ASP.Net

How to find the controls recursively in a Control in asp.net

Sajid P K

Author: Asha.MP             
Posted Date: October 12, 2010     Points: 5   


Please give an example for that,

Thanks and Regards,
Author: Sajid P K             
Posted Date: October 12, 2010     Points: 5   


I have Panal... in that panal many controls are there... it also contains another container control as well.

So i have get all the controls on the panal. Hope this clear to you now..

Author: Asha.MP             
Posted Date: October 13, 2010     Points: 5   

Hi Sajid..

i got your doubt,

here is the example code for that

This in in my aspx page
<asp:Panel ID="Pnltest" runat="server">
<asp:Label ID="LblTest1" runat="server" Text="1" ></asp:Label>
<asp:Label ID="LblTest2" runat="server" text="2" ></asp:Label>
<asp:TextBox ID="TxtTest1" runat ="server" Text="3" ></asp:TextBox>
<asp:Button ID="BtnCount" runat="server" Text="4" />
<asp:DropDownList ID="DdlControl" runat="server">

in the code behind you can get the controls name by using below code
'This is arraylist to store the control names
Dim list As New ArrayList
'This is to check the panel whether it has controls or not
If Me.Pnltest.HasControls = True Then
For i = 1 To Me.Pnltest.Controls.Count - 1 Step 2
'Adding the controls name to the list
End If

list stores the controls within the panel.

Is it clear???

Thanks and Regards,

Post Reply

You must Sign In To post reply
Find more Forum Questions on C#, ASP.Net, Vb.Net, SQL Server and more Here
Quick Links For Forum Categories:
ASP.NetWindows Application  .NET Framework  C#  VB.Net  ADO.Net  
Sql Server  SharePoint  OOPs  SilverlightIISJQuery

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend