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


Top 5 Contributors of the Month
david stephan

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
Frnds,

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


Regards,
Sajid P K

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

Hi...

Please give an example for that,

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

asha,

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">
</asp:DropDownList>
</asp:Panel>

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
list.Add(Me.Pnltest.Controls.Item(i).GetType.Name)
Next
End If

list stores the controls within the panel.

Is it clear???

Thanks and Regards,
Asha.mp


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
JavaScript/VBScriptBiztalkWPFPatten/PracticesWCFOthers
www.DotNetSpark.comUnAnsweredAll

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