Live Chat Icon For mobile
Live Chat Icon

How to get the list of all System.Web.UI.WebControls in my page

Platform: ASP.NET| Category: Controls

<asp:Repeater runat='server' DataSource=’<%# GetControls() %>’ ID='Repeater1'>
<HeaderTemplate>

    </HeaderTemplate> <ItemTemplate>
  • <%# DataBinder.Eval(Container.DataItem, 'Name') %>
  • </ItemTemplate> <FooterTemplate>
</FooterTemplate> </asp:Repeater>

VB.NET


Protected Function GetControls() As ArrayList
Dim arrList As New ArrayList()
Dim t As Type
   	For Each t In  GetType(Page).Assembly.GetTypes()
      		If t.Namespace = 'System.Web.UI.WebControls' And GetType(Control).IsAssignableFrom(t) Then
         			arrList.Add(t)
      		End If
   	Next 
Return arrList
End Function ’GetControls

’In Page_Load
DataBind()

C#


protected	ArrayList GetControls()
{
	ArrayList arrList = new ArrayList();
	foreach (Type t in typeof(Page ).Assembly.GetTypes())
	{
		if (t.Namespace == 'System.Web.UI.WebControls' && typeof(Control).IsAssignableFrom(t))
			arrList.Add(t);
	}
	return arrList;
}

//In Page_Load
DataBind();

Share with

Related FAQs

Couldn't find the FAQs you're looking for?

Please submit your question and answer.